Caches
This configures the caches in the runtime
Last updated
Was this helpful?
This configures the caches in the runtime
Last updated
Was this helpful?
BoxLang comes bundled with an enterprise caching engine that can be configured with different settings and backend object stores. It is also can give you the ability to register caches that adhere to our BoxCache interface (ICacheProvider
) to create an implementation agnostic API. Apart from the core providers we create, we also have several in our + subscriptions and anybody can build custom providers as well.
You can also define by defining them in the Application.bx
file in your applications.
Every BoxLang runtime comes pre-configured with the following caches that are mandatory for operation:
default
The default cache in BoxLang is used for queries, templates, and many more internal usages.
bxSessions
If you activate session management in your web or client applications, user session information will be stored here.
bxRegex
This is where all dynamic regular expressions are compiled and kept.
Here are the available providers for BoxLang. The table shows the status of completion of each provider and its availability for the open-source version of BoxLang, or if you are a +/++ subscriber.
BoxLang
The enterprise BoxLang native cache provider can leverage many different object stores.
Redis
A Redis single-node provider
RedisCluster
A Redis cluster cache provider
MongoDB
A Mong DB based Provider
Couchbase
A Couchbase based provider
ElasticSearch
An Elastic Search provider
EhCache
An EhCacheProvider
Every cache must be placed inside the caches
object with a unique name key. The value of that key contains:
provider
- The name of a core provider or a full classpath to use. Ex: BoxCacheProvider
which is the core one, or a module collaborated class or class path class: ortus.boxlang.modules.redis.RedisCache
properties
- An object of configuration for the provider.
Our BoxCacheProvider
is an enterprise-level cache designed to be fast and event-driven. Here are the available configuration options.
Here are the available object stores for our BoxCache providers.
BlackHoleStore
Mocking store, just simulates a store, nothing is stored.
ConcurrentSoftReferenceStore
Memory-sensitive storage leveraging Java Soft References.
ConcurrentStore
Leverages concurrent hashmaps for storage.
FileSystemStore
Stores the cache items in a serialized fashion on disk
JDCBStore
Stores caches in JDBC Databases
Each store can have different configuration properties as well.
Here are the global properties for all object stores.
How many objects can be evicted once a policy is triggered? The default is 1.
The eviction policy to use. The available policies are:
LRU (default): Least Recently Used
LFU: Least Frequently Used
FIFO: First in First out
LIFO: Last in Last Out
RANDOM: Randomly evict objects
The free memory percentage threshold to trigger eviction 0 = disabled, 1-100 = percentage of available free memory in heap. If the threshold is reached, the eviction policy is triggered. The default is 0.
The maximum number of objects to store in the cache. The default is 1000
The maximum number of seconds an object can be kept in the cache since its last access. If an object is not accessed at this time or greater, it will be removed from the cache. The default is 1800 seconds or 30 minutes.
The maximum time in seconds to keep an object in the cache regardless if it's used or not. A default timeout of 0 = never expire, careful with this setting. The default is 3600 seconds or 60 minutes.
The object store to use to store the objects. The default is a ConcurrentStore.
reapFrequency
The frequency in seconds to check for expired objects and expire them using the policy. This creates a BoxLang task that runs every X seconds to check for expired objects. The default is 120 seconds or 2 minutes.
If enabled, the last access timeout will be reset on every access for the cache entry. This means that the last access timeout will be reset to the defaultLastAccessTimeout
on every access. Usually for session caches or to simulate a session. The default is false.
If enabled, the last access timeout will be used to evict objects from the cache. Default is true.
These are the custom properties for this store:
The absolute path of the directory that will hold all the serialized cache entries on disk.