public interface Cache
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.
public MyCache(final String id) { if (id == null) { throw new IllegalArgumentException("Cache instances require an ID"); } this.id = id; initialize(); }
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears this cache instance.
|
String |
getId() |
Object |
getObject(Object key) |
default ReadWriteLock |
getReadWriteLock()
Optional.
|
int |
getSize()
Optional.
|
void |
putObject(Object key,
Object value) |
Object |
removeObject(Object key)
As of 3.3.0 this method is only called during a rollback
for any previous value that was missing in the cache.
|
String getId()
void putObject(Object key, Object value)
key
- Can be any object but usually it is a CacheKey
value
- The result of a select.Object getObject(Object key)
key
- The keyObject removeObject(Object key)
key
- The keyvoid clear()
int getSize()
default ReadWriteLock getReadWriteLock()
Any locking needed by the cache must be provided internally by the cache provider.
Copyright © 2009–2021 MyBatis.org. All rights reserved.