The cache-enabler project provides Redis Server-backed caching capabilities to the services. It uses rich API objects support provided by a Redisson library and implements the execution of both synchronous and asynchronous commands on the Redis Server. Synchronous methods bear asynchronous variants.
Following are the supported Redis connection configurations:
cache-enabler supports CRUD operations into the Redis server for these objects:
- Any entity type object along with the capability to add a score.
- Any
Stringobject along with its score.
cache-enabler also provides the capability to perform CRUD operations on a Map of entities.
Each object has a mutationId which is meant to be returned in asynchronous operations
NOTE: Support for pipelined batch executions are provided through the .*Async() methods. Clients of
redis-cacheare encouraged to use Async methods to improve throughput. For typical store and forget or store and retrieve slightly later use cases, Async methods will bring about quite a bit of throughput improvement.
- Getting Started
- Usage
- How to contribute
- Built with Dependencies
- Code of Conduct
- Authors
- Security Contact Information
- Support
- Troubleshooting
- License
- Announcements
To build the project in the local working directory after the project has been cloned/forked, run:
mvn clean install
from the command line interface.
- Maven
- Java 17
- Copy pre-compiled binary of redis server and pdb into src/test/resources
mvn test
Or run a specific test
mvn test -Dtest="TheFirstUnitTest"
To run a method from within a test
mvn test -Dtest="TheSecondUnitTest#whenTestCase2_thenPrintTest2_1"
The redis-cache project serves as a library for the services. It is not meant to be deployed as a service in a Cloud environment.
Add the following dependency in the target project
<dependency>
<groupId>org.eclipse.ecsp</groupId>
<artifactId>cache-enabler</artifactId>
<version>1.X.X</version>
</dependency>
| Operation | Parameter Required | Parameter Type | Parameter Description | Output Type |
|---|---|---|---|---|
| getString | key | String |
Key in redis for a String value |
String |
| getString | request | GetStringRequest |
Object with key and boolean parameter for namespace enabled | String |
| putString | putRequest | PutStringRequest |
Object with new value for a String key in redis and other additional information |
void |
| getEntity | key | String |
Key in redis for an IgniteEntity |
IgniteEntity |
| getEntity | request | GetEntityRequest |
Object with key and boolean parameter for namespace enabled | IgniteEntity |
| putEntity | putRequest | PutEntityRequest |
Object representation with IgniteEntity as value to put into cache along with other information |
void |
| addStringToScoredSortedSet | request | AddScoredStringRequest |
Object with score, key and value for adding a String to a scored sorted set |
void |
| getStringsFromScoredSortedSet | request | GetScoredStringsRequest |
Object with key, start, end, namespaceEnabled and reversed boolean parameter for getting a range of String from a scored sorted set |
List<String> |
| getEntitiesFromScoredSortedSet | request | GetScoredEntitiesRequest |
Object with key, start, end, namespaceEnabled and reversed boolean parameter for getting a range of IgniteEntity from a scored sorted set |
List<IgniteEntity> |
| addEntityToScoredSortedSet | request | AddScoredEntityRequest |
Object with key, entity, score, mutation Id and boolean parameter namespace enabled for adding an IgniteEntity to a scored sorted set |
void |
| putStringAsync | putRequest | PutStringRequest |
Object with value and additional information to put a String in redis in asynchronous mode |
void |
| putEntityAsync | putRequest | PutEntityRequest |
Object representation with IgniteEntity as value to put into cache in asynchronous mode along with other information |
void |
| addStringToScoredSortedSetAsync | request | AddScoredStringRequest |
Object with key, value, score, mutation Id and boolean parameter namespaceEnabled for adding a String to a scored sorted set in asynchronous mode |
void |
| addEntityToScoredSortedSetAsync | request | AddScoredEntityRequest |
Object with key, entity, score, mutation Id and boolean parameter namespaceEnabled for adding an IgniteEntity to a scored sorted set in asynchronous mode |
void |
| delete | key | String |
Key in redis to delete | void |
| delete | request | DeleteEntryRequest |
Object with key and boolean parameter for namespace enabled to delete a key | void |
| deleteAsync | request | DeleteEntryRequest |
Object with key and boolean parameter for namespace enabled to delete a key in asynchronous mode | void |
| putMapOfEntities | mapRequest | PutMapOfEntitiesRequest |
Object for putting a map of IgniteEntity into cache for a key |
void |
| getMapOfEntities | mapRequest | GetMapOfEntitiesRequest |
Object for getting a map of specific IgniteEntity specified by fields in the object for a key in the cache |
Map<String, IgniteEntity> |
| deleteMapOfEntities | request | DeleteMapOfEntitiesRequest |
Object for deleting a map of IgniteEntity specified by fields in the object for a key in the cache |
void |
All the redis related configuration needs to be specified on the environment, which can be referred here
Some configuration which decide the kind of connection to be made:
-
For running the library as a client of Redis with sentinels, the services need to set the below property:
redis.sentinels=<redis-sentinel-list> -
For running the library as a client of Redis clustered nodes, the services need to set the below property:
redis.cluster.masters=<xxxxx> -
If the above two configurations are not specified, the default configuration will be applied to run the application as a client for a single Redis server instance, the host of which is specified by:
redis.address=<xxxxxxx>
IgniteCacheRedisImpl also serves as a health monitor for health monitoring provided by the ignite-utils dependency.
If there are any exceptions raised in performing any operation with Redis, the health monitor is marked as Unhealthy.
cache-enabler provides the capability to execute batch operations with Redis in a reliable way. If a thread was performing a batch operation and another thread performed RBatch.execute() at the same time,
then first thread fails with IllegalStateException("Batch already has been executed").
| Dependency | Purpose |
|---|---|
| Ignite Utils | Provides logging support and health monitor for cache service |
| Ignite Transformers | Provides serialization and deserialization |
| Test Containers | Test Container support for testing in dockerized environment |
| Docker Java | Java API client for docker |
| Redisson | Redis Java Client with features of In-Memory Data Grid |
| Junit | Testing framework |
| Mockito | Test Mocking framework |
| Embedded Redis | Redis embedded server for Java integration testing |
| Commons IO | Library to assist with IO functionality |
Please read CONTRIBUTING.md for details on our contribution guidelines, and the process for submitting pull requests to us.
Please read CODE_OF_CONDUCT.md for details on our code of conduct.
![]() Kaushal Arora ๐ ๐ |
See also the list of contributors who participated in this project.
Please read SECURITY.md to raise any security related issues.
Please write to us at csp@harman.com
Please read CONTRIBUTING.md for details on how to raise an issue and submit a pull request to us.
This project is licensed under the Apache-2.0 License - see the LICENSE file for details.
All updates to this library are documented in our Release Notes and releases. For the versions available, see the tags on this repository.

