K
- the type of keys maintained by this mapV
- Type of objects stored in cachepublic class MemoryCache<K,V> extends Object implements Cacheable<K,V>
null
values.
Default policy parameters:
Constructor and Description |
---|
MemoryCache() |
MemoryCache(CachePolicy policy) |
MemoryCache(CachePolicy policy,
String name) |
MemoryCache(String name) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all of the mappings from this map (optional operation).
|
Set<Map.Entry<K,Cacheable.Entry<V>>> |
entrySet() |
V |
get(K key)
Returns the value to which the specified key is cached,
or
null if this cache contains no mapping for the key. |
Cacheable.Entry<V> |
getEntry(K key)
Returns a
Cacheable.Entry view of the mappings contained in this cache. |
String |
getName()
cache name
|
CachePolicy |
getPolicy()
policy that maintenance the capacity and expire time of data
|
V |
put(K key,
V object)
Associates the specified value with the specified key in this cache
If the cache previously contained a mapping for the key, the old value
is replaced by the specified value.
|
Cacheable.Entry<V> |
remove(K key) |
void |
setPolicy(CachePolicy policy)
Policy to control the cache data
|
long |
size()
Returns the number of key-value mappings in this map.
|
String |
toString() |
public MemoryCache()
public MemoryCache(String name)
public MemoryCache(CachePolicy policy)
public MemoryCache(CachePolicy policy, String name)
public CachePolicy getPolicy()
Cacheable
public void setPolicy(CachePolicy policy)
Cacheable
public V put(K key, V object)
Cacheable
public V get(K key)
Cacheable
null
if this cache contains no mapping for the key.public Cacheable.Entry<V> getEntry(K key)
Cacheable
Cacheable.Entry
view of the mappings contained in this cache.getEntry
in interface Cacheable<K,V>
key
- the key whose associated with entry is to be returnedCacheable.Entry
contained in this cache, or
null
if this map contains no mapping for the keypublic void clear()
Cacheable
public long size()
Cacheable
Copyright © 2012–2020 jkniv, copyleft code. All rights reserved.