Configuring 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.

Configuring a Cache Resource

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

Field Description

name

Name of the cache configuration that you’re creating. If empty, the custom resource (CR) name is used.

hazelcastResourceName

Defines the name of the Hazelcast resource for which the cache configuration is created.

backupCount

Count of synchronous backups.

asyncBackupCount

Count of asynchronous backups.

keyType

Fully qualified class name of the cache key type.

valueType

Fully qualified class name of the cache value type.

persistenceEnabled

When enabled, the cache data will be persisted.

inMemoryFormat

Represents the format 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
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, use the following command to check its status:

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