2.0.3 • Published 5 years ago

@landingexp/apollo-server-cache-redis v2.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

RedisCache

npm version Build Status

This package exports an implementation of KeyValueCache that allows using Redis as a backing store for resource caching in Data Sources.

It currently supports a single instance of Redis, Cluster and Sentinel.

Usage

Single instance

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(),
  }),
});

Sentinels

const { RedisCache } = require('apollo-server-cache-redis');

const server = new ApolloServer({
  typeDefs,
  resolvers,
  cache: new RedisCache({
    sentinels: [{
      host: 'sentinel-host-01',
      port: 26379
    }],
    password: 'my_password',
    name: 'service_name',
    // Options are passed through to the Redis client
  }),
  dataSources: () => ({
    moviesAPI: new MoviesAPI(),
  }),
});

Cluster

const { RedisClusterCache } = require('apollo-server-cache-redis');

const server = new ApolloServer({
  typeDefs,
  resolvers,
  cache: new RedisClusterCache(
    [{
      host: 'redis-node-01-host',
      // Options are passed through to the Redis cluster client
    }],
    {
      // Cluster options are passed through to the Redis cluster client
    }
  ),
  dataSources: () => ({
    moviesAPI: new MoviesAPI(),
  }),
});

For documentation of the options you can pass to the underlying redis client, look here.

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

1.2.2

5 years ago

2.0.0

5 years ago

1.2.3-alpha.0

5 years ago