Re: Extending the cache functionality

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Aug 29 2005 - 08:26:13 EDT

  • Next message: Gili: "Re: ant test fails"

    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



    This archive was generated by hypermail 2.0.0 : Mon Aug 29 2005 - 08:26:17 EDT