BoxCache Stores

BoxCache object stores provide the storage layer for cached data with different persistence and performance characteristics

Object stores are the foundational storage layer of the BoxLang cache engine. They provide the actual mechanism for storing, retrieving, and managing cached objects in memory, on disk, or in distributed databases. While cache providers coordinate user interactions and act as a service layer, object stores handle the low-level data persistence and retrieval operations.

🏗️ Store Architecture

BoxCache's flexible architecture allows you to choose the right storage backend for your caching needs:

  • In-Memory Stores - Fast, volatile storage for frequently accessed data

  • Disk-Based Stores - Persistent storage that survives application restarts

  • Database-Backed Stores - Distributed caching across multiple application instances

  • Special-Purpose Stores - Testing and development utilities

📦 Available Object Stores

Store
Type
Distributed
Best For

In-Memory

No

High-performance caching, frequently accessed data

In-Memory

No

Memory-sensitive applications, automatic garbage collection support

Disk-Based

No

Persistent caching, application restarts, compiled templates

Database

Yes

Multi-server deployments, load-balanced environments, horizontal scaling

Mock

No

Testing, development, cache simulation

🎯 Choosing the Right Store

Performance Requirements

  • Maximum SpeedConcurrentStore - Thread-safe in-memory storage with minimal overhead

  • Memory EfficiencyConcurrentSoftReferenceStore - Allows JVM to reclaim memory under pressure

  • PersistenceFileSystemStore - Survives restarts, ideal for compiled templates and configurations

  • DistributionJDBCStore - Share cache across multiple servers in clustered environments

Use Case Examples

High-Traffic Web Application:

{
    "provider": "BoxCacheProvider",
    "properties": {
        "objectStore": "ConcurrentStore",
        "maxObjects": 10000,
        "evictionPolicy": "LRU"
    }
}

Multi-Server Deployment:

{
    "provider": "BoxCacheProvider",
    "properties": {
        "objectStore": "JDBCStore",
        "datasource": "sharedCache",
        "table": "app_cache"
    }
}

Template Compilation Cache:

{
    "provider": "BoxCacheProvider",
    "properties": {
        "objectStore": "FileSystemStore",
        "directory": "/var/caches/templates"
    }
}

🔧 Common Configuration Properties

All object stores support the standard BoxCache configuration properties:

  • maxObjects - Maximum number of cached items

  • evictionPolicy - LRU, LFU, FIFO, LIFO, or RANDOM

  • evictCount - Number of items to evict when limit is reached

  • defaultTimeout - Time-to-live in seconds

  • defaultLastAccessTimeout - Idle timeout in seconds

  • reapFrequency - Cleanup frequency in seconds

Store-specific properties are documented on each store's individual page.

📚 Store-Specific Documentation

Click on any store below to view detailed configuration options, features, and usage examples:

🚀 Next Steps

  1. Choose your store based on performance, persistence, and distribution requirements

  2. Review the specific store documentation for configuration details

  3. Configure your cache in boxlang.json or Application.bx

  4. Test your configuration to ensure optimal performance

For general caching concepts and provider configuration, see the Caching Overview.

Last updated

Was this helpful?