[infinispan-dev] CassandraCacheStore

Galder Zamarreño galder at redhat.com
Wed Sep 8 12:32:57 EDT 2010


Hi Tristan,

First of all, welcome to the Infinispan community :)

On Sep 8, 2010, at 12:03 PM, Tristan Tarrant wrote:

> Dear all,
> 
> I am new here and I (would like to) bring gifts :)
> 
> First of all thanks for the great work you have been doing on Infinispan. I was introduced to Infinispan by Sanne, with whom I have collaborated in the past (hi Sanne!).
> 
> Over the last few days I have been writing a CacheStore implementation for Apache Cassandra, but I have a few unanswered questions I would like to submit to you before I proceed.
> 
> I have written my code by taking inspiration from other CacheStore providers, namely the JDBM and Hibernate stores.
> 
> I hash the key of an entry to produce an appropriate key for Cassandra. I then store the marshalled value in a Column named "entry" within a ColumnFamily named "Infinispan". If the entry has an expiration I create another Column within the "Infinispan" ColumnFamily using the following pattern: "expiration"+"0paddedtimestamp" containg a placeholder value.
> When purgeInternal is invoked I delete all rows which have a column in the range "Infinispan:expiration0000000000000000" to "Infinispan:expiration0paddednowtimestamp".
> I have noticed that the JDBM CacheStore keeps expiration entries in an internal LinkedHashMap: is that just for performance reasons ?

It might be cos it'd be too expensive to purge if metadata is maintained in the JDBM store. If the store can somehow be indexed by this data, then within a query you'd be able to delete all expired. However, if purging expired entries means navigating all entries to check if they're expired, then it wouldn't be very efficient. I believe JDBM cache store code maintains the expiry entry and queue in order to do this at more efficiently. If you can delete all rows whose column is in that range, seems like you already have the single query that you need to purge all expired data. 

> Also, Cassandra doesn't support transactional operations, but merely batched operations: within the applyModifications() method I just send all operations in one batch invocation. Is this ok ? I guess that Infinispan manages the transactional side of things.

Yeah, sounds good. The transactional part is covered as long as you extend from classes such as AbstractCacheStore.

> 
> I am currently developing in my own private Subversion repository and using my own package name and Junit+mockito in place of testng+easymock. Would such an object be worthy of potential inclusion within Infinispan itself (and so should I refactor everything around the org.infinispan package and integrate nicely with the rest of the tree?). Should I submit a patch to the current Infinispan trunk ?

Infinispan uses testng, so your tests should do so. In terms of package, you should put your classes under org.infinispan.loaders.cassandra. Also, each individual cache loader implementation should be kept on separate Maven project (see others for example), so you can simply send a patch or a zip with the full maven project so that we can review it.

Finally, thanks very much for working on this!! :)

> 
> Thanks in advance
> 
> Tristan
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev

--
Galder Zamarreño
Sr. Software Engineer
Infinispan, JBoss Cache




More information about the infinispan-dev mailing list