public class PersisterCache extends java.lang.Object implements Persister
Persister instance. Each cache instance is thread-safe,
but there is no guarantee of consistent behavior across multiple cache instances.| Constructor and Description |
|---|
PersisterCache(Persister persister) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this storage and cleans up any local client resources.
|
byte[] |
get(java.lang.String path)
Retrieves the previously stored data at the specified path, or throws an exception if the path doesn't exist.
|
java.util.Collection<java.lang.String> |
getChildren(java.lang.String path)
Returns the names of child nodes at the provided path.
|
java.util.Map<java.lang.String,byte[]> |
getMany(java.util.Collection<java.lang.String> paths)
Atomically reads many values from storage at once, returning a mapping of paths to values.
|
void |
recursiveDelete(java.lang.String path)
Recursively deletes the data at the specified path, or throws an exception if no data existed at that location.
|
void |
recursiveDeleteMany(java.util.Collection<java.lang.String> paths)
Atomically deletes many values from storage at once, with each path entry being treated as a call to
Persister.recursiveDelete(String) for those paths. |
void |
refresh()
Refreshes the cache with the underlying persister's data.
|
void |
set(java.lang.String path,
byte[] bytes)
Writes a single value to storage at the specified path, replacing any existing data at the path or creating the
path if it doesn't exist yet.
|
void |
setMany(java.util.Map<java.lang.String,byte[]> pathBytesMap)
Atomically writes many values to storage at once.
|
public PersisterCache(Persister persister) throws PersisterException
PersisterExceptionpublic byte[] get(java.lang.String path)
throws PersisterException
Persisternull.get in interface PersisterPersisterException - if the requested path doesn't exist, or for other access errorspublic java.util.Collection<java.lang.String> getChildren(java.lang.String path)
throws PersisterException
Persisternull data when
retrieved via Persister.get(String), indicating that these are stub parent entries to other nodes.
To translate the returned values to full absolute paths, they may be joined with the provided path
input using PersisterUtils.join(String, String).
To get the list of nodes at the root, use "" or "/" as the input path.
getChildren in interface PersisterPersisterException - if the requested path doesn't exist, or for other access errorspublic void set(java.lang.String path,
byte[] bytes)
throws PersisterException
Persisterset in interface PersisterPersisterException - in the event of an access errorpublic java.util.Map<java.lang.String,byte[]> getMany(java.util.Collection<java.lang.String> paths)
throws PersisterException
PersisterMap.getMany in interface PersisterPersisterException - in the event of an access errorPersister.get(String)public void setMany(java.util.Map<java.lang.String,byte[]> pathBytesMap)
throws PersisterException
PersistersetMany in interface PersisterPersisterException - in the event of an access error, in which case no changes should have been madePersister.set(String, byte[])public void recursiveDeleteMany(java.util.Collection<java.lang.String> paths)
throws PersisterException
PersisterPersister.recursiveDelete(String) for those paths.recursiveDeleteMany in interface PersisterPersisterException - in the event of an access error, in which case no changes should have been madePersister.recursiveDelete(String)public void recursiveDelete(java.lang.String path)
throws PersisterException
PersisterDeleting the root node (as "" or "/") will result in all nodes EXCEPT the root node being deleted.
recursiveDelete in interface PersisterPersisterException - if the data at the requested path didn't exist, or for other access errorspublic void close()
Persisterpublic void refresh()
throws PersisterException
PersisterException