Extending the cache functionality

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Extending the cache functionality

Gili

        I can quite easily extend our LRU map to add TTL and max-idle values
per entries stores within. In my application, for example, I want to be
able to say that image objects should be cached for a maximum of 5 minutes.

        Originally I had requested a feature that allows us to specify the
maximum cache size in terms of bytes but look back at EHCache (used by
Hibernate) it doesn't allow this either. Still, I think this would be
worthwhile to add if we can do so efficiently because the bottom line is
end-users don't care how many objects exist in the cache, what they
*really* want to configure is the total memory usage of the cache.

        The question is, how difficult would it be for you to implement
DataObject.size() which returns the size of any given DataObject in
bytes? This wouldn't have to be 100% exact (we could fine-tune the
result over future releases) but I think it should be relatively easy
(and quick) to return an approximate value by iterating through the
DataRows making up any given DataObject and suming up each individual
column size contribution.

        What do you think?

Thanks,
Gili
--
http://www.desktopbeautifier.com/
Reply | Threaded
Open this post in threaded view
|

Re: Extending the cache functionality

Andrus Adamchik
On Aug 29, 2005, at 1:14 AM, Gili wrote:

>     I can quite easily extend our LRU map to add TTL and max-idle  
> values per entries stores within. In my application, for example, I  
> want to be able to say that image objects should be cached for a  
> maximum of 5 minutes.

TTL would be cool. When you are talking about TTL, you mean a fixed  
time SINCE "put" was called, regardless of how recently "get" was  
called on this entry?


>     Originally I had requested a feature that allows us to specify  
> the maximum cache size in terms of bytes but look back at EHCache  
> (used by Hibernate) it doesn't allow this either. Still, I think  
> this would be worthwhile to add if we can do so efficiently because  
> the bottom line is end-users don't care how many objects exist in  
> the cache, what they *really* want to configure is the total memory  
> usage of the cache.
>
>     The question is, how difficult would it be for you to implement  
> DataObject.size() which returns the size of any given DataObject in  
> bytes? This wouldn't have to be 100% exact (we could fine-tune the  
> result over future releases) but I think it should be relatively  
> easy (and quick) to return an approximate value by iterating  
> through the DataRows making up any given DataObject and suming up  
> each individual column size contribution.

Shared cache stores DataRows that are simple maps of values and  
values are usually Strings, Numbers and Dates (plus anything you  
might have as an ExtendedType). So if you want to play with the size  
estimation algorithm, you can implement it externally... E.g. in your  
custom LRUMap. I am not very excited about this idea though - when  
you make cache heavier and slower, caching benefits become dubious.  
But if you can show that it still performs well...

BTW, making cache map class fully declarative should be fairly easy -  
we may define a new property understood by DataRowStore that holds a  
Map class and create it via reflection.

Andrus

Reply | Threaded
Open this post in threaded view
|

Re: Extending the cache functionality

Gili


Andrus Adamchik wrote:

> On Aug 29, 2005, at 1:14 AM, Gili wrote:
>
>>     I can quite easily extend our LRU map to add TTL and max-idle  
>> values per entries stores within. In my application, for example, I  
>> want to be able to say that image objects should be cached for a  
>> maximum of 5 minutes.
>
> TTL would be cool. When you are talking about TTL, you mean a fixed  
> time SINCE "put" was called, regardless of how recently "get" was  
> called on this entry?

        Right.

> BTW, making cache map class fully declarative should be fairly easy -  
> we may define a new property understood by DataRowStore that holds a  
> Map class and create it via reflection.

        What does it mean for the cache map to be "fully declarative"?

Thanks,
Gili
Reply | Threaded
Open this post in threaded view
|

Re: Extending the cache functionality

Andrus Adamchik

On Aug 29, 2005, at 8:33 AM, Gili wrote:

>> BTW, making cache map class fully declarative should be fairly  
>> easy -  we may define a new property understood by DataRowStore  
>> that holds a  Map class and create it via reflection.
>>
>
>     What does it mean for the cache map to be "fully declarative"?

Sorry, I meant the actual class implementing java.util.Map can be  
specified declaratively.

Andrus