BoxLang 🚀 A New JVM Dynamic Language Learn More...
|:------------------------------------------------------: |
| ⚡︎ B o x L a n g ⚡︎
| Dynamic : Modular : Productive
|:------------------------------------------------------: |
This module provides standalone Redis and Redis Cluster cache providers for BoxLang runtimes.
To include the module in your boxlang runtime, follow the
instructions for module installation appropriate to your
runtime, using bx-redis as the module name/slug.
Versions 1.0.0 and above will require a Boxlang+ Subscription. Without
subscription, the module will operate within trial mode for 30 days.
After this period, the module will be placed in developer mode, which
will limit cache host connections only to 127.0.0.1 and localhost.
Feature Requests and Bug Reports may be submitted via JIRA.
If you file a bug report, your issue should contain a title, a clear description of the issue, a way to replicate the issue, and any support files that we might need to replicate your issue. The goal of a bug report is to make it easy for yourself - and others - to replicate the bug and develop a fix for it. All issues that do not contain a way to replicate will not be addressed.
If you have any questions on usage, professional support or just ideas to bounce off the maintainers, please do not create an issue. Leverage our support channels first.
boxlang.json configurationThe JSON configuration structure for boxlang for a single redis
connection would be placed in the caches object in boxlang.json
{
"caches" : {
"sessions": {
"provider": "Redis",
"properties": {
"cacheKeyCaseSensitivity": "false",
"database": "0",
"idleConnections": "5",
"maxConnections": "50",
"password": "",
"timeout": "2000",
"useSSL": "false",
"host": "127.0.0.1",
"keyprefix": "resources",
"port": "6379",
"timeout" : 2000,
"readTimeout" : 2000,
"socketTimeout" : 2000,
"poolWaittimeout" : 1000,
"maxAttempts" : 10,
"maxConnections": 1000,
"maxIdleTime" : 30000,
"maxIdleConnections" : 20,
"trackExpirations": false
}
}
}
}
trackExpirations(defaultfalse): Whentrue, the provider subscribes to Redis keyspace expiry notifications so thegetSize()counter decrements automatically when TTL-based expiry occurs, keeping it exact rather than approximate. Requiresnotify-keyspace-eventsto includeKx(e.g.,KxorKEA) on the Redis server — this setting cannot be configured from the client on Valkey Serverless or AWS ElastiCache without a parameter group change at the infrastructure level. Also requires a non-emptykeyprefixto safely filter expiry events. Whenfalse(default),getSize()is still O(1) but may slightly over-count entries that expired naturally via TTL.
{
"caches" : {
"resources": {
"provider": "RedisCluster",
"properties": {
"hosts": "node1.myrediscluster,node2.myrediscluster,node3.myrediscluster,",
"keyprefix": "boxlang-cluster",
"username": "${REDIS_CLUSTER_USERNAME}",
"password": "${REDIS_CLUSTER_PASSWORD}",
"port": "6379",
"useSSL": "${REDIS_CLUSTER_USE_SSL:false}",
"timeout" : 2000,
"readTimeout" : 2000,
"socketTimeout" : 2000,
"poolWaittimeout" : 1000,
"maxAttempts" : 10,
"maxConnections": 1000,
"maxIdleTime" : 30000,
"maxIdleConnections" : 20
"cacheKeyCaseSensitivity": "false",
}
}
}
}
{
"caches" : {
"resources": {
"provider": "RedisSentinel",
"properties": {
"sentinels": "sentinel1.myhost.com:26379,sentinel2.myhost.com:26379",
"keyprefix": "boxlang-sentinel",
"username": "${REDIS_SENTINEL_USERNAME}",
"password": "${REDIS_SENTINEL_PASSWORD}",
"cacheKeyCaseSensitivity": "false",
"database": "0",
"idleConnections": "5",
"maxConnections": "50",
"password": "",
"timeout": "2000",
"useSSL": "false",
"keyprefix": "resources",
"timeout" : 2000,
"readTimeout" : 2000,
"socketTimeout" : 2000,
"poolWaittimeout" : 1000,
"maxAttempts" : 10,
"maxConnections": 1000,
"maxIdleTime" : 30000,
"maxIdleConnections" : 20
}
}
}
}
Application.bx/Application.cfc configurationthis.caches[ "sessions" ] = {
"provider": "Redis",
"properties": {
"cacheKeyCaseSensitivity": "false",
"database": "0",
"idleConnections": "5",
"maxConnections": "50",
"password": "",
"timeout": "2000",
"useSSL": "false",
"host": "127.0.0.1",
"keyprefix": "boxlang-sessions",
"port": "6379",
"timeout" : 2000,
"socketTimeout" : 2000,
"poolWaittimeout" : 1000,
"maxConnections": 1000,
"idleConnections": 10
}
};
this.caches[ "resources" ] = {
"provider": "RedisCluster",
"properties": {
"hosts": "node1.myrediscluster,node2.myrediscluster,node3.myrediscluster,",
"keyprefix": "boxlang-cluster",
"username": myClusterUsername,
"password": myClusterPassword,
"port": "6379",
"useSSL": false,
"timeout" : 2000,
"readTimeout" : 2000,
"socketTimeout" : 2000,
"poolWaittimeout" : 1000,
"maxAttempts" : 10,
"maxConnections": 1000,
"maxIdleTime" : 30000,
"maxIdleConnections" : 20
}
};
The Redis server IP address or host name.
The port of the Redis server.
The logical database to connect to in Redis. By default we connect to database 0.
The Redis cluster username - only used when enabling user-level access.
The password of the Redis server, if any.
Enable SSL on the connection to the Redis Server.
The time in milliseconds to wait for a connection or throw an exception.
The cluster connection socket timeout in milliseconds
The the maximum amount of time, in milliseconds, to wait for a connection pool resource to become available
The maximum number of connections to allow to the Redis server.
The maximum number of idle connections to keep in the pool to the Redis server
The default key prefix is boxlang-cache. This will
automatically prefix EVERY single cache item that goes into Redis.
This will allow you to avoid collisions if you decide to register many
Lucee caches or just to distinguish what comes from which cache connection.
By default all cache keys are transformed to lowercase to avoid any casing issues. However, if you want case sensitivity, then turn this option on.
Enter a comma-delimited list of all the IPs or hosts in the cluster. Not all are needed, but you should at least enter some to have redundancy.
The port of the Redis cluster.
Whether SSL transport is enabled
The Redis cluster username - only used when enabling user-level access.
The Redis cluster password
The time in milliseconds to wait for a connection or throw an exception.
The timeout for a read of data from the cluster - defaults to the connection timeout
The cluster connection socket timeout in milliseconds
The the maximum amount of time, in milliseconds, to wait for a connection pool resource to become available
The maximum number of connections to the cluster allowed per pool - defaults to 50
The max idle time, in milliseconds, for a connection to remain in the pool.
The maximum number of concurrently idle connections to retain in the pool
The maximum number of connection attempts to make to the cluster.
The default key prefix is lucee-cache. This will
automatically prefix EVERY single cache item that goes into Redis.
This will allow you to avoid collisions if you decide to register many
Lucee caches or just to distinguish what comes from which cache connection.
By default all cache keys are transformed to lowercase to avoid any casing issues. However, if you want case sensitivity, then turn this option on.
Copyright Since 2023 by Ortus Solutions, Corp
www.boxlang.io | www.ortussolutions.com
Â
BoxLang is a professional open-source project and it is completely funded by the community and Ortus Solutions, Corp. Ortus Patreons get many benefits like a cfcasts account, a FORGEBOX Pro account and so much more. If you are interested in becoming a sponsor, please visit our patronage page: https://patreon.com/ortussolutions
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
KEYS enumeration with cursor-based SCAN across standalone, cluster, and sentinel providersclearAll() in all providers to use RedisKeyScanner.scanKeys() directly, eliminating the round-trip through keys() → prefix stripping → buildKey() — now uses SCAN+DEL in a single passgetSize() is now O(1) via a per-cache Redis INCR/DECR counter (__bxrc:{cacheName}:size); no longer scans the full keyspace on every call — resolves monitoring timeouts on Valkey Serverless / AWS ElastiCache with large keyspacestrackExpirations boolean config property (default false): when true, subscribes to Redis keyspace expiry notifications (__keyevent@{db}__:expired) so the size counter decrements automatically when TTL-based expiry occurs; requires notify-keyspace-events to include Kx on the server (not available on Valkey Serverless without a parameter group change)getKeys() output and cleanKeys() now filter out internal __bxrc: counter keys so they never appear in user-visible key listsredis.clients:jedis from 7.2.1 to 7.5.2ILock and ILockableCacheProvider interfaces for Redis modulebx:lock component backed by RedisLocklock() for distributed lock operationsLockTest and DistributedLockTest test coverageredis.clients:jedis from 7.2.0 to 7.2.1redis.clients:jedis from 7.0.0 to 7.2.0com.diffplug.spotless from 8.0.0 to 8.1.0bx-plus dependency for box.json and Module Config loaderbox.json typeRedisSentinelCache)resetTimeoutOnAccess config setting.github/copilot-instructions.md with validated commands and workflowsspotlessApply requirement for Copilot commitsredisPublish(), redisSubscribe()redisGetProvider(), redisGetCluster(), redisGetClusterNodes(), redisGetConnectionPool()toDuration() to use defaults, as it can lead to casting issues since they are dynamically typed, this is to adapt to the new core.
$
box install bx-redis