In memory cache for graphql-hooks
npm install graphql-hooks-memcacheIn-memory caching implementation for graphql-hooks
npm install graphql-hooks-memcache
or
yarn add graphql-hooks-memcache
This is intended to be used as the cache option when calling createClient from graphql-hooks.
``js
import { GraphQLClient } from 'graphql-hooks'
import memCache from 'graphql-hooks-memcache'
const client = new GraphQLClient({
url: '/graphql',
cache: memCache()
})
`
memCache(options): Option object properties
- size: The number of items to store in the cachettl
- : Milliseconds an item will remain in cache. The default behaviour will only evict items when the size limit has been reachedinitialState
- : The value from cache.getInitialState() used for rehydrating the cache after SSR
- cache.get(key): Find the item in the cache that matches keycache.set(key, value)
- : Set an item in the cachecache.delete(key)
- : Delete an item from the cachecache.clear()
- : Clear all items from the cachecache.keys()
- : Returns an array of keys, useful when you need to iterate over the cache itemscache.getInitialState()`: A serialisable version of the cache - used during SSR
-