Socket
Book a DemoInstallSign in
Socket

graphql-hooks-memcache

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-hooks-memcache

In memory cache for graphql-hooks

latest
Source
npmnpm
Version
3.2.0
Version published
Weekly downloads
3.5K
-18.04%
Maintainers
2
Weekly downloads
 
Created
Source

graphql-hooks-memcache

In-memory caching implementation for graphql-hooks

Install

npm install graphql-hooks-memcache

or

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({
  url: '/graphql',
  cache: memCache()
})

Options

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

API

  • 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

Keywords

graphql

FAQs

Package last updated on 19 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.