[infinispan-dev] Infinispan REST server

Manik Surtani manik at jboss.org
Mon Sep 7 09:39:49 EDT 2009


On 2 Sep 2009, at 00:29, Michael Neale wrote:

> On Thu, Aug 27, 2009 at 9:22 PM, Manik Surtani<manik at jboss.org> wrote:
>>
>> Entries are stored internally as InternalCacheEntry [1] instances.   
>> If
>> you look at the object hierarchy, ICE is implemented by
>> ImmortalCacheEntry, MortalCacheEntry, TransientCacheEntry and
>> TransientMortalCacheEntry (ah, for Scala traits to make this
>> cleaner!  :)
>>
>>
>> Where do you see a use for this information?  And in what cases do  
>> you
>> need it - i.e., for all entries?  Only entries that specify a  
>> lifespan
>> or maxIdle?
>
> OK - what I am doing is serving and taking content from a RESTful http
> interface - that means I need (ideally) Content-Type and Last-Modified
> headers...
>> From the sounds of it, there isn't an easy and reliable way to get
> this out of the core (certainly not the content type, I would have to
> guess...)
>
> So what I did is create a CacheEntry object, which wraps the data as a
> byte[], and has both a timestamp and the content-type (as a MIME media
> type).
> I am thinking I should move this to core in case someone wants to
> programmatically from the java api get to the data, and needs to know
> the MIME type (eg for indexing, or publishing) - good idea?

Perhaps.  But the name needs to change since it will clash with other  
internal types.

How about

org.infinispan.util.RichCacheValue {
	Object cacheValue;
	Map<String, String> metaData;
}

> If there is an element in the cache that someone wants to do a GET on
> which is NOT an instance of CacheEntry, I can probably work out how to
> stream that to them (and guess the content type) - either that or we
> just do all content as application/octet-stream (but I am trying to
> provide a most excellent REST interface for great good !)....
>
>>
>> [1] http://fisheye.jboss.org/browse/Infinispan/trunk/core/src/main/java/org/infinispan/container/entries/InternalCacheEntry.java?r=433
>>
>
> Excellent - so there seems to be at least a created timestamp here
> (which may or may not be what I want) - how would one go about getting
> at this from the Cache inferface (via casting) in a reasonably future
> safe way?

You can't at this stage.  You'd need to write an interceptor or  
something to get a hold of this at the moment.  I could expose an API  
in AdvancedCache to expose this via a getCacheEntry() method though.   
Do you think you need this?

Cheers
--
Manik Surtani
manik at jboss.org
Lead, Infinispan
Lead, JBoss Cache
http://www.infinispan.org
http://www.jbosscache.org







More information about the infinispan-dev mailing list