mirror of
https://github.com/vale981/apollo-server
synced 2025-03-06 02:01:40 -05:00
26 lines
953 B
Markdown
26 lines
953 B
Markdown
## RedisCache
|
|
|
|
[](https://badge.fury.io/js/apollo-server-cache-redis)
|
|
[](https://circleci.com/gh/apollographql/apollo-server)
|
|
|
|
This package exports an implementation of `KeyValueCache` that allows using Redis as a backing store for resource caching in [Data Sources](https://www.apollographql.com/docs/apollo-server/v2/features/data-sources.html).
|
|
|
|
## Usage
|
|
|
|
```js
|
|
const { RedisCache } = require('apollo-server-cache-redis');
|
|
|
|
const server = new ApolloServer({
|
|
typeDefs,
|
|
resolvers,
|
|
cache: new RedisCache({
|
|
host: 'redis-server',
|
|
// Options are passed through to the Redis client
|
|
}),
|
|
dataSources: () => ({
|
|
moviesAPI: new MoviesAPI(),
|
|
}),
|
|
});
|
|
```
|
|
|
|
For documentation of the options you can pass to the underlying redis client, look [here](https://github.com/NodeRedis/node_redis).
|