apollo-server-redis-cache

0.1.22 • Public • Published

apollo-server-redis-cache

Installation

$ npm install apollo-server-redis-cache

Usage

Start redis server

$ redis-server
import express from 'express'
import { graphqlExpress } from 'apollo-server-express'
import apolloServerRedisCache from 'apollo-server-redis-cache'
 
const _schema = /* your schema */
const PORT = 3000;
 
const app = express();
 
const redisCache = new apolloServerRedisCache({ cache: true, key: 'asrc', ttl: 60, httpHeader: 'X-My-Cache' });
 
app.use(
  '/graphql',
  bodyParser.json(),
  (req, res, next) => {
    res.use_redis_cache = req.cookies[USER_TOKEN] ? false : true;
    next();
  },
  redisCache.middleware(),
  graphqlExpress({ schema: _schema })
);
 
app.listen(PORT);

Package Sidebar

Install

npm i apollo-server-redis-cache

Weekly Downloads

7

Version

0.1.22

License

MIT

Unpacked Size

6.86 kB

Total Files

4

Last publish

Collaborators

  • bderen
  • jorisroling