public class PrefixKeyHashingScheme extends java.lang.Object implements KeyHashingScheme
KeyHashingScheme
decorator that simply adds
a known prefix to the results of another KeyHashingScheme
.
Primarily useful for namespacing a shared memcached cluster, for
example.Modifier and Type | Field and Description |
---|---|
private KeyHashingScheme |
backingScheme |
private java.lang.String |
prefix |
Constructor and Description |
---|
PrefixKeyHashingScheme(java.lang.String prefix,
KeyHashingScheme backingScheme)
Creates a new
KeyHashingScheme that prepends the given
prefix to the results of hashes from the given backing scheme. |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
hash(java.lang.String storageKey)
Maps a storage key to a cache key.
|
private final java.lang.String prefix
private final KeyHashingScheme backingScheme
public PrefixKeyHashingScheme(java.lang.String prefix, KeyHashingScheme backingScheme)
KeyHashingScheme
that prepends the given
prefix to the results of hashes from the given backing scheme.
Users should be aware that memcached has a fixed maximum key
length, so the combination of this prefix plus the results of
the backing hashing scheme must still fit within these limits.prefix
- backingScheme
- public java.lang.String hash(java.lang.String storageKey)
KeyHashingScheme
hash
in interface KeyHashingScheme
storageKey
- what the higher-level HTTP cache wants to use
as its key for looking up cache entries