> **Experimental**
>
> `@aws-cdk/aws-elasticache-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# CacheEngine

Supported cache engines together with available versions.

Named instances cover the versions currently available on ElastiCache Serverless.
To target a version that is not yet represented by a named instance, use
`CacheEngine.of(engineType, majorEngineVersion)`.

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`lib/serverless-cache-base.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0-alpha.0/packages/@aws-cdk/aws-elasticache-alpha/lib/serverless-cache-base.ts#L22)

## Example

```ts
declare const vpc: ec2.Vpc;

const serverlessCache = new elasticache.ServerlessCache(this, 'ServerlessCache', {
  engine: elasticache.CacheEngine.VALKEY_LATEST,
  backup: {
    // set a backup name before deleting a cache
    backupNameBeforeDeletion: "my-final-backup-name",
  },
  vpc,
});
```

## Properties

- `engineType`: string — The engine type, for example `'valkey'`, `'redis'`, or `'memcached'`.

  Maps directly to the `Engine` property of `AWS::ElastiCache::ServerlessCache`.

- `majorEngineVersion`: string — The major engine version, for example `'9'` or `'1.6'`. Maps directly to the `MajorEngineVersion` property of `AWS::ElastiCache::ServerlessCache`. When `undefined`, the service selects the latest major version automatically.

- `MEMCACHED_1_6`: [CacheEngine](/cdk/api/v2/docs/@aws-cdk_aws-elasticache-alpha.CacheEngine.html) (static) — Memcached engine, minor version 1.6, patch version is selected automatically.

- `MEMCACHED_LATEST`: [CacheEngine](/cdk/api/v2/docs/@aws-cdk_aws-elasticache-alpha.CacheEngine.html) (static) — Memcached engine, latest major version available, minor version is selected automatically.

- `REDIS_7`: [CacheEngine](/cdk/api/v2/docs/@aws-cdk_aws-elasticache-alpha.CacheEngine.html) (static) — Redis engine, major version 7, minor version is selected automatically.

- `REDIS_LATEST`: [CacheEngine](/cdk/api/v2/docs/@aws-cdk_aws-elasticache-alpha.CacheEngine.html) (static) — Redis engine, latest major version available, minor version is selected automatically.

- `VALKEY_7`: [CacheEngine](/cdk/api/v2/docs/@aws-cdk_aws-elasticache-alpha.CacheEngine.html) (static) — Valkey engine, major version 7, minor version is selected automatically.

- `VALKEY_8`: [CacheEngine](/cdk/api/v2/docs/@aws-cdk_aws-elasticache-alpha.CacheEngine.html) (static) — Valkey engine, major version 8, minor version is selected automatically.

- `VALKEY_9`: [CacheEngine](/cdk/api/v2/docs/@aws-cdk_aws-elasticache-alpha.CacheEngine.html) (static) — Valkey engine, major version 9, minor version is selected automatically.

- `VALKEY_LATEST`: [CacheEngine](/cdk/api/v2/docs/@aws-cdk_aws-elasticache-alpha.CacheEngine.html) (static) — Valkey engine, latest major version available, minor version is selected automatically.

## Methods

- `of(engineType: string, majorEngineVersion?: string): CacheEngine // chainable` (static) — Create a new `CacheEngine` with an arbitrary engine type and major version.

  Use this for engine/version combinations that are not yet represented by a
  named static member.

  **Parameters**

  - `engineType` — the engine type (for example, `'valkey'`, `'redis'`, or `'memcached'`).
  - `majorEngineVersion` — the major engine version (for example, `'9'`).

- `toString(): string` — Returns a string representation of this cache engine, for logging and error messages.

  The format is `engineType_majorEngineVersion` when a
  major version is set, or just `engineType` otherwise (for example,
  `'valkey_8'`, `'memcached_1.6'`, `'redis'`).
