> For the complete documentation index, see [llms.txt](https://expresso.masb0ymas.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://expresso.masb0ymas.com/expresso-library/expresso-provider/redis.md).

# Redis

{% hint style="info" %}
Redis Provider for expressjs
{% endhint %}

{% embed url="<https://www.npmjs.com/package/ioredis>" %}
memory cache with ioredis
{% endembed %}

Using commonjs

```javascript
const { Redis } = require('expresso-provider')
```

Using ES6

```javascript
import { Redis } from 'expresso-provider'
```

***

### Initialize Redis

```javascript
// config/redis.ts

import { Redis } from 'expresso-provider'

export const redisService = new Redis({
  host: '127.0.0.1',
  port: 6379,
  password: 'your_password',
})
```

***

### Using Redis

```javascript
import { redisService } from 'config/redis'
import { ms } from 'expresso-core'

const keyRedis = 'your_key'
const storeRedis = {
  'text': 'any value'
}
const expires = ms('10m')

// Set Redis
await redisService.set(keyRedis, JSON.stringify(storeRedis), {
  timeout: expires,
})

// Get Redis
const getStore = redisService.get(keyRedis)
```
