FileSystemStore
Disk-based persistent cache store with file system storage for durability across restarts
The FileSystemStore leverages disk-based storage to persist cache items as serialized entities on the file system. This store provides durability across application restarts and is highly efficient for caching scenarios that require persistence without the complexity of a database.
✨ Features
Persistent Storage: Cache survives application restarts
Efficient Serialization: Uses optimized Java serialization for fast read/write operations
File-Based Management: Each cache entry stored as a separate file for easy inspection
Automatic Cleanup: Expired entries are automatically removed during reaping
Directory-Based Organization: Simple file system structure for cache storage
Eviction Support: Compatible with all BoxCache eviction policies (LRU, LFU, FIFO, LIFO, RANDOM)
📋 Configuration Example
"diskCache": {
"provider": "BoxCacheProvider",
"properties": {
"objectStore": "FileSystemStore",
"directory": "/var/caches/app_cache",
"maxObjects": 5000,
"evictionPolicy": "LRU",
"evictCount": 50,
"defaultTimeout": 7200,
"defaultLastAccessTimeout": 3600,
"reapFrequency": 300
}
}⚙️ Configuration Properties
directory (required)
The absolute path of the directory that will hold all the serialized cache entries on disk. The directory will be created if it doesn't exist (requires appropriate file system permissions).
Standard BoxCache Properties
The FileSystemStore supports all standard BoxCache configuration properties:
maxObjects (recommended)
The maximum number of objects to store in the cache. Default is 1000.
evictionPolicy
The eviction policy to use when the cache reaches capacity. Options: LRU, LFU, FIFO, LIFO, RANDOM. Default is LRU.
evictCount
How many objects to evict when the cache reaches capacity. Default is 1.
defaultTimeout
The maximum time in seconds to keep an object in the cache regardless of access. 0 = never expire. Default is 3600 (1 hour).
defaultLastAccessTimeout
The maximum time in seconds since last access before an object expires. Default is 1800 (30 minutes).
reapFrequency
How often (in seconds) to check for and remove expired objects. Default is 120 (2 minutes).
resetTimeoutOnAccess
If true, the last access timeout resets on every access (session-like behavior). Default is false.
useLastAccessTimeouts
If true, the last access timeout is used for eviction. Default is true.
💡 Usage Examples
Template Compilation Cache
Application Configuration Cache
Asset Processing Cache
🎯 Best Practices
🗂️ File System Structure
The FileSystemStore creates a simple, flat directory structure:
Each cache entry is stored as a separate .ser file named after the cache key (with special characters escaped). This makes it easy to:
Inspect cache contents using file system tools
Manually clear specific cache entries if needed
Backup/restore cache data
Monitor cache size using disk usage tools
🔗 Related Resources
ConcurrentStore - For in-memory caching
JDBCStore - For distributed caching scenarios
BlackHoleStore - For testing without persistence
Last updated
Was this helpful?
