Package com.aquima.web.sessionmanager
Class NamespacedKeyValueStore
- java.lang.Object
-
- com.aquima.web.sessionmanager.NamespacedKeyValueStore
-
- All Implemented Interfaces:
com.blueriq.component.api.store.keyvalue.IKeyValueStore
public class NamespacedKeyValueStore extends Object implements com.blueriq.component.api.store.keyvalue.IKeyValueStore
AnIKeyValueStore
wrapper which causes all keys to be namespaced by prefixing them with an specified namespace string followed by the the colon character.For example, if the namespace is "example", then calling
set("test", "value")
will set the "example:test" key in the key-value store.- Since:
- 11.0
- Author:
- Petru Galanton
-
-
Constructor Summary
Constructors Constructor Description NamespacedKeyValueStore(com.blueriq.component.api.store.keyvalue.IKeyValueStore delegate, String namespace)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete(String key)
void
deleteAll(String... keys)
<T> T
deserialize(byte[] bytes, Class<T> valueType)
boolean
expire(String key, long timeout, TimeUnit unit)
<T extends Serializable>
Tget(String key, Class<T> valueType)
com.blueriq.component.api.store.keyvalue.IKeyPatternBuilder
getKeyPatternBuilder()
String
getNamespacedKey(String key)
Applies the namespace to the given key and returns the result.String
getNamespaceSeparator()
byte[]
getRaw(String key)
boolean
hasKey(String key)
com.blueriq.component.api.store.keyvalue.IKeyValueStore.IKeyIterator
keyIterator(com.blueriq.component.api.store.keyvalue.IKeyPattern pattern)
byte[]
serialize(Serializable value)
void
set(String key, Serializable value)
void
set(String key, Serializable value, long timeout, TimeUnit unit)
void
setRaw(String key, byte[] value)
void
setRaw(String key, byte[] value, long timeout, TimeUnit unit)
-
-
-
Constructor Detail
-
NamespacedKeyValueStore
public NamespacedKeyValueStore(com.blueriq.component.api.store.keyvalue.IKeyValueStore delegate, String namespace)
Creates a new instance.- Parameters:
delegate
- - the delegate IKeyValueStore implementationnamespace
- - the key namespace, must not benull
- Throws:
IllegalArgumentException
- ifnamespace
isnull
-
-
Method Detail
-
set
public void set(String key, Serializable value)
- Specified by:
set
in interfacecom.blueriq.component.api.store.keyvalue.IKeyValueStore
-
set
public void set(String key, Serializable value, long timeout, TimeUnit unit)
- Specified by:
set
in interfacecom.blueriq.component.api.store.keyvalue.IKeyValueStore
-
setRaw
public void setRaw(String key, byte[] value)
- Specified by:
setRaw
in interfacecom.blueriq.component.api.store.keyvalue.IKeyValueStore
-
setRaw
public void setRaw(String key, byte[] value, long timeout, TimeUnit unit)
- Specified by:
setRaw
in interfacecom.blueriq.component.api.store.keyvalue.IKeyValueStore
-
get
public <T extends Serializable> T get(String key, Class<T> valueType)
- Specified by:
get
in interfacecom.blueriq.component.api.store.keyvalue.IKeyValueStore
-
getRaw
public byte[] getRaw(String key)
- Specified by:
getRaw
in interfacecom.blueriq.component.api.store.keyvalue.IKeyValueStore
-
delete
public void delete(String key)
- Specified by:
delete
in interfacecom.blueriq.component.api.store.keyvalue.IKeyValueStore
-
deleteAll
public void deleteAll(String... keys) throws IllegalArgumentException
- Specified by:
deleteAll
in interfacecom.blueriq.component.api.store.keyvalue.IKeyValueStore
- Throws:
IllegalArgumentException
-
hasKey
public boolean hasKey(String key)
- Specified by:
hasKey
in interfacecom.blueriq.component.api.store.keyvalue.IKeyValueStore
-
expire
public boolean expire(String key, long timeout, TimeUnit unit)
- Specified by:
expire
in interfacecom.blueriq.component.api.store.keyvalue.IKeyValueStore
-
keyIterator
public com.blueriq.component.api.store.keyvalue.IKeyValueStore.IKeyIterator keyIterator(com.blueriq.component.api.store.keyvalue.IKeyPattern pattern)
- Specified by:
keyIterator
in interfacecom.blueriq.component.api.store.keyvalue.IKeyValueStore
-
getNamespaceSeparator
public String getNamespaceSeparator()
- Specified by:
getNamespaceSeparator
in interfacecom.blueriq.component.api.store.keyvalue.IKeyValueStore
-
getKeyPatternBuilder
public com.blueriq.component.api.store.keyvalue.IKeyPatternBuilder getKeyPatternBuilder()
- Specified by:
getKeyPatternBuilder
in interfacecom.blueriq.component.api.store.keyvalue.IKeyValueStore
-
serialize
public byte[] serialize(Serializable value)
- Specified by:
serialize
in interfacecom.blueriq.component.api.store.keyvalue.IKeyValueStore
-
deserialize
public <T> T deserialize(byte[] bytes, Class<T> valueType)
- Specified by:
deserialize
in interfacecom.blueriq.component.api.store.keyvalue.IKeyValueStore
-
-