Interface IObjectStore
- All Known Implementing Classes:
AbstractStore,BlackHoleStore,ConcurrentSoftReferenceStore,ConcurrentStore,FileSystemStore
public interface IObjectStore
The main interface for object storages for a BoxLangCache.
This store can be used to store objects in memory or in a persistent storage or whatever you want.
A cache provider coordinates user interactions an acts more like a cache service to the underlying
cache store.
Each object store must adhere to this interface and will receive
Key objects as keys so the
object store can decide how to store the objects if in case-sensitive or case-insensitive manner.
Each object store will also use the ICacheEntry to store the data so it's consistent across
all cache providers and stores.
You can implement your own store to store objects in a different way or create your own
cache provider to talk to different Caches as well.-
Method Summary
Modifier and TypeMethodDescriptionbooleanClears an object from the storageClears multiple objects from the storagevoidclearAll()Clear all the elements in the storebooleanclearAll(ICacheKeyFilter filter) Clear all the elements in the store with a $ICacheKeyFilter.voidevict()Runs the eviction algorithm to remove objects from the store based on the eviction policy and eviction count.intflush()Flush the store to a permanent storage.get(ICacheKeyFilter filter) Get multiple objects from the store with metadata tracking using a filterGet an object from the store with metadata trackingGet multiple objects from the store with metadata trackingGet the configuration for the storeKey[]getKeys()Get all the keys in the storeKey[]getKeys(ICacheKeyFilter filter) Get all the keys in the store using a filterGet all the keys in the store as a streamgetKeysStream(ICacheKeyFilter filter) Get all the keys in the store as a streamgetName()Get the name of the storeGet the associated cache providergetQuiet(ICacheKeyFilter filter) Get multiple objects from the store with no metadata tracking using a filterGet an object from cache with no metadata trackingGet multiple objects from the store with no metadata trackingintgetSize()Get the size of the store, not the size in bytes but the number of objects in the storeinit(ICacheProvider provider, IStruct config) Some storages require a method to initialize the storage or do object loading.lookup(ICacheKeyFilter filter) Check if multiple objects are in the store using a filterbooleanCheck if an object is in the storeCheck if multiple objects are in the storevoidset(Key key, ICacheEntry entry) Sets an object in the storagevoidSet's multiple objects in the storagevoidshutdown()Some storages require a shutdown method to close the storage or do object saving.
-
Method Details
-
getName
String getName()Get the name of the store- Returns:
- The name of the store
-
getConfig
IStruct getConfig()Get the configuration for the store -
getProvider
ICacheProvider getProvider()Get the associated cache provider -
init
Some storages require a method to initialize the storage or do object loading. This method is called when the cache provider is started.- Parameters:
provider- The cache provider associated with this storeconfig- The configuration for the store
-
shutdown
void shutdown()Some storages require a shutdown method to close the storage or do object saving. This method is called when the cache provider is stopped. -
flush
int flush()Flush the store to a permanent storage. Only applicable to stores that support it.- Returns:
- The number of objects flushed
-
evict
void evict()Runs the eviction algorithm to remove objects from the store based on the eviction policy and eviction count. -
getSize
int getSize()Get the size of the store, not the size in bytes but the number of objects in the store -
clearAll
void clearAll()Clear all the elements in the store -
clearAll
Clear all the elements in the store with a $ICacheKeyFilter. This can be a lambda or method reference since it's a functional interface.- Parameters:
filter- The filter that determines which keys to clear- Returns:
- The number of objects cleared
-
clear
Clears an object from the storage- Parameters:
key- The object key to clear- Returns:
- True if the object was cleared, false otherwise (if the object was not found in the store)
-
clear
Clears multiple objects from the storage- Parameters:
keys- The key(s) to clear- Returns:
- A struct of keys and their clear status
-
getKeys
Key[] getKeys()Get all the keys in the store- Returns:
- An array of keys in the cache
-
getKeys
Get all the keys in the store using a filter- Parameters:
filter- The filter that determines which keys to return- Returns:
- An array of keys in the cache
-
getKeysStream
Get all the keys in the store as a stream- Returns:
- A stream of keys in the cache
-
getKeysStream
Get all the keys in the store as a stream- Parameters:
filter- The filter that determines which keys to return- Returns:
- A stream of keys in the cache
-
lookup
Check if an object is in the store- Parameters:
key- The key to lookup in the store- Returns:
- True if the object is in the store, false otherwise
-
lookup
Check if multiple objects are in the store- Parameters:
keys- A varargs of key(s) to lookup in the store- Returns:
- A struct of keys and their lookup status
-
lookup
Check if multiple objects are in the store using a filter- Parameters:
filter- The filter that determines which keys to return- Returns:
- A struct of keys and their lookup status
-
get
Get an object from the store with metadata tracking- Parameters:
key- The key to retrieve- Returns:
- The cache entry retrieved or null
-
get
Get multiple objects from the store with metadata tracking- Parameters:
keys- The key(s) to retrieve- Returns:
- A struct of keys and their cache entries
-
get
Get multiple objects from the store with metadata tracking using a filter- Parameters:
filter- The filter that determines which keys to return- Returns:
- A struct of keys and their cache entries
-
getQuiet
Get an object from cache with no metadata tracking- Parameters:
key- The key to retrieve- Returns:
- The cache entry retrieved or null
-
getQuiet
Get multiple objects from the store with no metadata tracking- Parameters:
keys- The key(s) to retrieve- Returns:
- A struct of keys and their cache entries
-
getQuiet
Get multiple objects from the store with no metadata tracking using a filter- Parameters:
filter- The filter that determines which keys to return- Returns:
- A struct of keys and their cache entries
-
set
Sets an object in the storage- Parameters:
key- The key to store the object underentry- The cache entry to store
-
set
Set's multiple objects in the storage- Parameters:
entries- The keys and cache entries to store
-