# Set Redis Key Example

> Demonstrates setting Redis keys for caching or session management in API Maker.

Source: https://docs.apimaker.dev/v1/examples/sys/cache/setKey.html

`g.sys.cache.setKey` calls the [set redis key system API](https://docs.apimaker.dev/v1/docs/apis-all/system-apis/system-generated-set-redis-key-api.html) from your code.

### Set redis keys

Set redis key using global object 'g'.

```ts
await g.sys.cache.setKey([
    {
        key: "redis_key_name",
        value: "redis_key_value",
        ttl: 1500  // This key will be available till next 1500 seconds.
    },
    {
        key: "redis_key_name",
        value: "redis_key_value"
    }
]);
```

## Related

- [Set redis key system API](https://docs.apimaker.dev/v1/docs/apis-all/system-apis/system-generated-set-redis-key-api.html) · [Automatic caching](https://docs.apimaker.dev/v1/docs/features/automatic-caching.html) · [The global object g](https://docs.apimaker.dev/v1/docs/pre-defined-terms/global-object-g.html)
