Class ConcurrentSoftReferenceStore
java.lang.Object
ortus.boxlang.runtime.cache.store.AbstractStore
ortus.boxlang.runtime.cache.store.ConcurrentSoftReferenceStore
- All Implemented Interfaces:
IObjectStore
This object store keeps all objects in heap using Concurrent classes.
Naturally the store is ordered by
created
timestamp and can be used for concurrent access.-
Field Summary
Fields inherited from class ortus.boxlang.runtime.cache.store.AbstractStore
config, provider
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Clears an object from the storageClears multiple objects from the storagevoid
clearAll()
Clear all the elements in the storeboolean
clearAll
(ICacheKeyFilter filter) Clear all the elements in the store with a $ICacheKeyFilter
.void
evict()
Runs the eviction algorithm to remove objects from the store based on the eviction policy and eviction count.void
Evict soft references from the store that have been collectedint
flush()
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 tracking: hits, lastAccess, etcGet multiple objects from the store with metadata trackingKey[]
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 streamgetPool()
Get the pool of objects ConcurrentStore uses a ConcurrentHashMap to store the objectsgetQuiet
(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 trackingint
getSize()
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 filterboolean
Check if an object is in the storeCheck if multiple objects are in the storevoid
set
(Key key, ICacheEntry entry) Sets an object in the storagevoid
Set's multiple objects in the storagevoid
shutdown()
Some storages require a shutdown method to close the storage or do object saving.Methods inherited from class ortus.boxlang.runtime.cache.store.AbstractStore
buildPolicyByName, getConfig, getName, getPolicy, getProvider
-
Constructor Details
-
ConcurrentSoftReferenceStore
public ConcurrentSoftReferenceStore()Constructor
-
-
Method Details
-
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
-
getPool
Get the pool of objects ConcurrentStore uses a ConcurrentHashMap to store the objects- Returns:
- The pool of objects
-
shutdown
public 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
public int flush()Flush the store to a permanent storage. Only applicable to stores that support it. Not supported by this pool.- Returns:
- The number of objects flushed
-
evict
public void evict()Runs the eviction algorithm to remove objects from the store based on the eviction policy and eviction count. -
getSize
public int getSize()Get the size of the store, not the size in bytes but the number of objects in the store -
clearAll
public 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 keys to clear- Returns:
- A struct of keys and their clear status: true if the object was cleared, false otherwise (if the object was not found in the store)
-
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 keys 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 the keys found. True if the object is in the store, false otherwise
-
get
Get an object from the store with metadata tracking: hits, lastAccess, etc- Parameters:
key
- The key to retrieve- Returns:
- The cache entry retrieved or null if not found
-
get
Get multiple objects from the store with metadata tracking- Parameters:
keys
- The keys 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 multiple objects from the store with no metadata tracking- Parameters:
keys
- The keys 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
-
getQuiet
Get an object from cache with no metadata tracking- Parameters:
key
- The key to retrieve- Returns:
- The cache entry retrieved or null if not found
-
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
-
evictSoftReferences
public void evictSoftReferences()Evict soft references from the store that have been collected
-