T
- the type of values maintained by this mappublic class HashDataCache<T extends Serializable> extends Object implements DataCache<T>
Modifier and Type | Class and Description |
---|---|
static class |
HashDataCache.Pair<K,V>
Key/Value pair.
|
Constructor and Description |
---|
HashDataCache(DataCache<HashDataCache.Pair<String,T>> cache)
Creates cache hashing with default SHA-512 algorithm.
|
HashDataCache(DataCache<HashDataCache.Pair<String,T>> cache,
MessageDigest md)
Creates cache hashing with given algorithm.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all of the mappings from this cache.
|
T |
get(String key)
Lookup pair key/value by hashkey but verify found key matches original key.
|
String |
hash(String key)
Get the hash encoding of a key string.
|
boolean |
set(String key,
T value)
Put a value on a key in a data cache.
|
public HashDataCache(DataCache<HashDataCache.Pair<String,T>> cache, MessageDigest md)
cache
- provided underlying cachemd
- the MessageDigest to extract hash algorithmMessageDigest.getInstance(String)
public HashDataCache(DataCache<HashDataCache.Pair<String,T>> cache)
cache
- provided underlying cachepublic String hash(String key)
key
- The input string to encode.public final T get(String key)
get
in interface DataCache<T extends Serializable>
key
- The key whose associated value is to be returnedpublic final boolean set(String key, T value)
DataCache
set
in interface DataCache<T extends Serializable>
key
- the key under which this object should be added.value
- the object to storepublic void clear()
DataCache
clear
in interface DataCache<T extends Serializable>
Copyright © 2016–2018 Yahoo! Inc.. All rights reserved.