Caches
This configures the caches in the runtime

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 per-application caches by defining them in the Application.bx file in your applications.
Default Caches
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 for each provider and its availability for the open-source version of BoxLang, as well as for +/++ subscribers.
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 MongoDB based Provider
Couchbase
A Couchbase based provider
ElasticSearch
An Elastic Search provider
EhCache
An EhCacheProvider
You can also find more providers through third-party providers at www.forgebox.io.
Configuration
Every cache must be placed inside the cachesobject 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:BoxCacheProviderwhich is the core one, or a module collaborated class or class path class:ortus.boxlang.modules.redis.RedisCacheproperties- An object of configuration for the provider.
BoxCache Provider
Our BoxCacheProvideris an enterprise-level cache designed to be fast and event-driven. Here are the available configuration options.
Object Stores
Object stores are the foundational storage layer of the BoxLang cache engine. They provide the actual mechanism for storing, retrieving, and managing cached objects. While cache providers coordinate user interactions and act as a service layer, object stores handle the low-level data persistence and retrieval operations.
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
JDBCStore
Distributed cache store backed by JDBC databases for multi-instance cache sharing
Each store can have different configuration properties as well.
Global Properties
Here are the global properties for all object stores.
evictCount
How many objects can be evicted once a policy is triggered? The default is 1.
evictionPolicy
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
freeMemoryPercentageThreshold
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.
maxObjects
The maximum number of objects to store in the cache. The default is 1000
defaultLastAccessTimeout
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.
defaultTimeout
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.
objectStore
The object store to use to store the objects. The default is a ConcurrentStore.
reapFrequency
reapFrequencyThe 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.
resetTimeoutOnAccess
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.
useLastAccessTimeouts
If enabled, the last access timeout will be used to evict objects from the cache. The default is true.
Object Stores
BoxCache supports multiple object store backends for different caching scenarios. Each store provides different persistence, performance, and distribution characteristics.
For detailed information about each store type, including configuration examples and best practices, see the BoxCache Stores documentation:
ConcurrentStore - High-performance in-memory caching (default)
ConcurrentSoftReferenceStore - Memory-sensitive caching with automatic GC support
FileSystemStore - Disk-based persistent caching
JDBCStore - Database-backed distributed caching (New in 1.7.0)
BlackHoleStore - Mock store for testing
Each store page includes:
Features and capabilities
Complete configuration examples
Store-specific properties
Usage patterns and best practices
Performance considerations
When to use each store type
Last updated
Was this helpful?
