Skip to content
Branch: master
Find file History
jackdclark chore(release): 🚀
 - create-react-app@0.1.4
 - fastify-ssr@1.0.4
 - graphql-hooks-memcache@1.2.0
 - graphql-hooks-ssr@1.1.0
 - graphql-hooks@3.4.0
Latest commit 4cd7d07 Mar 18, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
test test: Add test for graphql-hooks-memcache (#122) Mar 11, 2019
index.d.ts feat: add a TypeScript declaration file for graphql-hooks-memcache (#137 Mar 15, 2019
rollup.config.js feat: cjs, es & umd bundles for graphql-hooks-memcache (#109) Mar 7, 2019


In-memory caching implementation for graphql-hooks


npm install graphql-hooks-memcache


yarn add graphql-hooks-memcache

Quick Start

This is intended to be used as the cache option when calling createClient from graphql-hooks.

import { GraphQLClient } from 'graphql-hooks'
import memCache from 'graphql-hooks-memcache'

const client = new GraphQLClient({
  endpoint: '/graphql',
  cache: memCache()


memCache(options): Option object properties

  • size: The number of items to store in the cache
  • ttl: Milliseconds an item will remain in cache. The default behaviour will only evict items when the size limit has been reached
  • initialState: The value from cache.getInitialState() used for rehydrating the cache after SSR


  • cache.get(key): Find the item in the cache that matches key
  • cache.set(key, value): Set an item in the cache
  • cache.delete(key): Delete an item from the cache
  • cache.clear(): Clear all items from the cache
  • cache.keys(): Returns an array of keys, useful when you need to iterate over the cache items
  • cache.getInitialState(): A serialisable version of the cache - used during SSR
You can’t perform that action at this time.