Nodule memcached client bindings
Nodule-memcached is a library wrapper around the Memcached client, porting code from memcached-promisify
and using it in the nodule-graphql context, binding the client to the graph,
This library assumes that in the config
object of your nodule-config
container
you have a few config keys:
config.cache.enabled
- true/falseconfig.cache.memcached.hosts
- a comma-delimited array of memcached hostsconfig.cache.memcached
- an object configuring the Memcached client itself (see API here)
inside a nodule-graphql
project's app.js:
import { bindServices } from '@globality/nodule-graphql';
import initializeCacheClient from '@globality/nodule-memcached';
// inside createApp()
initializeCacheClient();
initializeCacheClient
binds the cache client on the graph, the client is accessible by:
const { client } = getContainer();
The memcached client itself is also available for import:
import { Cache } from from '@globality/nodule-memcached';
const client = new Cache({hosts: 'host1,host2', ...});
Local development of nodule-memcached
with other repos has a few common pitfalls related to the
usage of peer dependencies:
nodule-config
is a peer-dependency because various libraries act as plugins to it and it needs a single import ofbottlejs
to share plugin state
To work with nodule-memcached
locally:
-
Run
yarn build
withinnodule-memcached
to transpile the source. -
Change directories to your local repo that you want to test against
nodule-memcached
. -
Run
yarn add /path/to/nodule-memcached
to copy the transpiled source into your local repo. Do NOT useyarn link
-
After running
yarn add
, remove (or move-of-the-way) thenodule_modules
from withinnodule_modules/@globality/nodule-memcached/