Constructor and Description |
---|
SimpleCache() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear (i.e.
|
Value |
get(Key key)
Retrieve an element from the cache.
|
Value |
getIfLoaded(Key key)
Retrieve and return an element from the cache if it's already there or
return
null otherwise. |
RefResolver<Key,Value> |
getResolver()
Return the
RefResolver used to load data in the cache. |
boolean |
isLoaded(Key key)
Return
true if the element with the given key is currently in the
cache and false otherwise. |
void |
remove(Key key)
Force removal of an element from the cache.
|
void |
setResolver(RefResolver<Key,Value> resolver)
Set the
RefResolver to be used to load data in the cache. |
int |
size()
Return the number of elements currently in the cache.
|
public Value get(Key key)
HGCache
Retrieve an element from the cache. If the element is already in the cache,
it is simply returned. Otherwise, the RefResolver
will be used to
obtain it automatically from permanent storage.
public Value getIfLoaded(Key key)
HGCache
Retrieve and return an element from the cache if it's already there or
return null
otherwise. This method will not call the
RefResolver
when the element is not found in the cache.
getIfLoaded
in interface HGCache<Key,Value>
key
- The key of the element.null
is it's not found in the cache.public boolean isLoaded(Key key)
HGCache
Return true
if the element with the given key is currently in the
cache and false
otherwise.
public void remove(Key key)
HGCache
Force removal of an element from the cache. This method is generally used when the data has been (or is being) removed from the permanent storage as well.
public RefResolver<Key,Value> getResolver()
HGCache
Return the RefResolver
used to load data in the cache.
getResolver
in interface HGCache<Key,Value>
public void setResolver(RefResolver<Key,Value> resolver)
HGCache
Set the RefResolver
to be used to load data in the cache.
setResolver
in interface HGCache<Key,Value>
public void clear()
HGCache
Clear (i.e. force removal of) all elements from the cache.
Copyright © 2015. All rights reserved.