K
- Type of keys in the cacheV
- Type of values in the cachepublic class Cache<K,V> extends Object
ConcurrentHashMap
.Constructor and Description |
---|
Cache()
Creates a new instance of
Cache . |
Cache(int initialSize)
Creates a new instance of
Cache . |
Cache(int initialSize,
float loadFactor)
Creates a new instance of
Cache . |
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(K key)
Checks if the give key is in this cache.
|
V |
get(K key)
Returns the cached value for the given key.
|
V |
put(K key,
V value)
Puts the given entry into this cache.
|
int |
size()
Returns the size of this cache.
|
public Cache()
Cache
.public Cache(int initialSize)
Cache
.initialSize
- initial sizepublic Cache(int initialSize, float loadFactor)
Cache
.initialSize
- initial sizeloadFactor
- load factorpublic V get(K key)
key
- the keynull
, if
the given key does not exist in this cache.public V put(K key, V value)
key
- the keyvalue
- the valuepublic boolean containsKey(K key)
key
- the keytrue
, if the given key exists in the cache;
false
, otherwise.public int size()
Copyright © 2016. All rights reserved.