/** * SPI for cache providers. * * One instance of cache will be created for each namespace. * * The cache implementation must have a constructor that receives the cache id as an String parameter. * * MyBatis will pass the namespace as id to the constructor. * * <pre> * public MyCache(final String id) { * if (id == null) { * throw new IllegalArgumentException("Cache instances require an ID"); * } * this.id = id; * initialize(); * } * </pre> * * @author Clinton Begin */
publicinterfaceCache{
/** * @return The identifier of this cache */ String getId();
/** * @param key Can be any object but usually it is a {@link CacheKey} * @param value The result of a select. */ voidputObject(Object key, Object value);
/** * @param key The key * @return The object stored in the cache. */ Object getObject(Object key);
/** * Optional. It is not called by the core. * * @param key The key * @return The object that was removed */ Object removeObject(Object key);
/** * Clears this cache instance */ voidclear();
/** * Optional. This method is not called by the core. * * @return The number of elements stored in the cache (not its capacity). */ intgetSize();
/** * Optional. As of 3.2.6 this method is no longer called by the core. * * Any locking needed by the cache must be provided internally by the cache provider. * * @return A ReadWriteLock */ ReadWriteLock getReadWriteLock();