net.java.ao.cache
Class RAMCache

java.lang.Object
  extended by net.java.ao.cache.RAMCache
All Implemented Interfaces:
Cache

public class RAMCache
extends Object
implements Cache

Author:
Daniel Spiewak

Constructor Summary
RAMCache()
           
 
Method Summary
 CacheLayer createCacheLayer(RawEntity<?> entity)
          Retrieves a CacheLayer instance which corresponds to the given entity.
 void dispose()
          Frees all resources associated with the cache.
 RelationsCache getRelationsCache()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RAMCache

public RAMCache()
Method Detail

createCacheLayer

public CacheLayer createCacheLayer(RawEntity<?> entity)
Description copied from interface: Cache

Retrieves a CacheLayer instance which corresponds to the given entity. CacheLayer instance(s) may themselves be cached within the value cache, but this is not part of the specification. Generically, this method should return an instance of a working CacheLayer implementation which can persist values relevant to the given entity in an implementation-specific way. For example, the default implementation of this interface (RAMCache) returns a CacheLayer which can cache values in memory for a specific entity.

Typically, instances of the same implementation are returned for any given entity (e.g. RAMCacheLayer always returns an instance of RAMValueCache, regardless of the entity in question). It is theoretically possible however to differentiate layers based on entity type or even specific primary key value. I'm not sure why you would want to do this, but there's nothing in the requirements which would prevent it. Code which uses the result of this method should certainly be written to the interface, rather than any specific implementation.

Specified by:
createCacheLayer in interface Cache
Parameters:
entity - TODO
Returns:
A layer which will handle caching of values as necessary for the given entity.

dispose

public void dispose()
Description copied from interface: Cache
Frees all resources associated with the cache. This should be used to handle things like closing connections, freeing result-sets, etc. This method will be called by EntityManager on the old ValueCache when a new instance is specified.

Specified by:
dispose in interface Cache
See Also:
EntityManager.setCache(Cache)

getRelationsCache

public RelationsCache getRelationsCache()
Specified by:
getRelationsCache in interface Cache


Copyright © 2007-2010. All Rights Reserved.