Class PrefixKeyHashingScheme
- java.lang.Object
-
- org.apache.http.impl.client.cache.memcached.PrefixKeyHashingScheme
-
- All Implemented Interfaces:
KeyHashingScheme
public class PrefixKeyHashingScheme extends java.lang.Object implements KeyHashingScheme
This is aKeyHashingScheme
decorator that simply adds a known prefix to the results of anotherKeyHashingScheme
. Primarily useful for namespacing a shared memcached cluster, for example.
-
-
Constructor Summary
Constructors Constructor Description PrefixKeyHashingScheme(java.lang.String prefix, KeyHashingScheme backingScheme)
Creates a newKeyHashingScheme
that prepends the given prefix to the results of hashes from the given backing scheme.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
hash(java.lang.String storageKey)
Maps a storage key to a cache key.
-
-
-
Constructor Detail
-
PrefixKeyHashingScheme
public PrefixKeyHashingScheme(java.lang.String prefix, KeyHashingScheme backingScheme)
Creates a newKeyHashingScheme
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.- Parameters:
prefix
-backingScheme
-
-
-
Method Detail
-
hash
public java.lang.String hash(java.lang.String storageKey)
Description copied from interface:KeyHashingScheme
Maps a storage key to a cache key. The storage key is what the higher-level HTTP cache uses as a key; the cache key is what we use as a key for talking to memcached.- Specified by:
hash
in interfaceKeyHashingScheme
- Parameters:
storageKey
- what the higher-level HTTP cache wants to use as its key for looking up cache entries- Returns:
- a cache key suitable for use with memcached
-
-