Discussions

Performance and scalability: Simple LRU caching with expiration

  1. Simple LRU caching with expiration (6 messages)

    Sometimes you just need a quick and simple caching implementation without all the fuss and muss of jar files, configuration, etc. Here is a free and simple solution for those that are interested.
    http://simple-software.ca/lru.jsp

    Threaded Messages (6)

  2. do they cache their site?[ Go to top ]

    The site doesn't answer.

    Does it use cache?
  3. EHCache,OSCache,etc[ Go to top ]

    EHCache requests a few .jars but a also a few lines of code, and a optional config file..

    'component' based programming is always best, you design the system right the first time.

    don't cut corners.
  4. EHCache,OSCache,etc[ Go to top ]

    EHCache requests a few .jars but a also a few lines of code, and a optional config file.. 'component' based programming is always best, you design the system right the first time.don't cut corners.

    I took a look at EHCache. Couple of things:

    Their map interface seems to take an 'Element', which requires a serializable key and value. So one has to make sure that their objects are serializable -- minor, whatever, just pointing it out. Sometimes one is not in control of all of the objects.

    It is mentioned in their documentation about an expiry time, but looking through the JavaDoc, I did not see any place where I could specify an expiry time on a cached object... Probably I just missed it somewhere?? Setting a variable expiration time (different expiration for different objects) happens to be important for my code.

    Cheers,

    Ian
  5. EHCache,OSCache,etc[ Go to top ]

    EHCache requests a few .jars but a also a few lines of code, and a optional config file.. 'component' based programming is always best, you design the system right the first time.don't cut corners.
    I took a look at EHCache. Couple of things:Their map interface seems to take an 'Element', which requires a serializable key and value. So one has to make sure that their objects are serializable -- minor, whatever, just pointing it out. Sometimes one is not in control of all of the objects.It is mentioned in their documentation about an expiry time, but looking through the JavaDoc, I did not see any place where I could specify an expiry time on a cached object... Probably I just missed it somewhere?? Setting a variable expiration time (different expiration for different objects) happens to be important for my code.Cheers,Ian



        timeToIdleSeconds - Sets the time to idle for an element before it expires.
                                             i.e. The maximum amount of time between accesses before an element expires
                                             Is only used if the element is not eternal.
                                             Optional attribute. A value of 0 means that an Element can idle for infinity.
                                             The default value is 0.
            timeToLiveSeconds - Sets the time to live for an element before it expires.
                                             i.e. The maximum time between creation time and when an element expires.
                                             Is only used if the element is not eternal.
                                             Optional attribute. A value of 0 means that and Element can live for infinity.
                                             The default value is 0.



    instead of expiry time, they use timeToLive.
    which is set in the ehcache.xml, which must be on your classpath.

      <cache name="com.vanitysoft.MyObject"
            maxElementsInMemory="10000"
            eternal="true"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            diskPersistent="false"
            overflowToDisk="true"
        />

    :)

    a note, i switched from EHCache to OSCache because OSCache supports clustering..
    Jeryl Cook
  6. EHCache,OSCache,etc[ Go to top ]

    This still does not look like a per object expiration time to me (different times for different objects).
  7. JCS[ Go to top ]

    The latest, mature version of JCS is far better than EHCache. Not only is it faster, it has more features and a much better disk cache.

    http://jakarta.apache.org/jcs/getting_started/intro.html

    http://jakarta.apache.org/jcs/JCSvsEHCache.html