Skip to main content
Version: 5.17

Configure cache

Hazelcast offers a specification-compliant JCache implementation. The Hazelcast JCache implementation is 100% TCK (Technology Compatibility Kit) compliant and therefore passes all specification requirements. You can create and configure JCache using the Cache custom resource.

Configure a cache resource​

You can use any of the following configuration options in the Cache resource. For more information, see the API reference.

FieldDescription
nameName of the cache that you're creating. If empty, the custom resource (CR) name is used.
hazelcastResourceNameThe name of the Hazelcast resource.
backupCountCount of synchronous backups.
asyncBackupCountCount of asynchronous backups.
keyTypeFully qualified class name of the cache key type.
valueTypeFully qualified class name of the cache value type.
persistenceEnabledWhen enabled, the cache data will be persisted.
inMemoryFormatFormat options for storing the data in cache.

Example configuration​

The following Cache custom resource creates a cache configuration for the Hazelcast custom resource that is defined in the hazelcastResourceName field.

Example configuration
yaml
apiVersion: hazelcast.com/v1alpha1
kind: Cache
metadata:
name: cache-sample
spec:
hazelcastResourceName: hazelcast
backupCount: 1
asyncBackupCount: 0
inMemoryFormat: NATIVE
keyType: java.lang.Object
valueType: java.lang.Object
persistenceEnabled: false

After creating the Cache resource, you can check its status:

shell
kubectl get cache cache-sample -o wide
NAME STATUS HAZELCAST-RESOURCE MESSAGE
cache-sample Success hazelcast