benoitemile / apollo-redis-cache

Apollo server redis cache implementation to handle fail, catch errors

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

apollo-redis-cache

This package is a fork of Apollo Server Cache Redis but written in javascript and with the goal of having the Apollo Server always up even if Redis server is down.

RedisCache

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.

Usage

Single instance

import { RedisCache } from 'apollo-redis-cache';

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.

About

Apollo server redis cache implementation to handle fail, catch errors

License:MIT License


Languages

Language:JavaScript 100.0%