Node key/value store, using GitHub gists for persistent storage.
Clone or download
Simon Thompson
Simon Thompson Bump version number
Latest commit c03b74f Oct 25, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Sep 24, 2017
README.md Tidying + formatting Sep 26, 2017
ghks.js Fix bug preventing the cache from generating Oct 25, 2017
package.json Bump version number Oct 25, 2017

README.md

ghks

Basic key/value store for Node, using GitHub gists for persistent storage.

Basic Usage

const ghks = require( './ghks' );

// Create new cache.
let cache = new ghks( {
	name: 'ghdb_example',
	token: '{YOUR_GITHUB_TOKEN}'
} );

cache.init().then( function() {
	cache.set( 'Fruit', 'Apple' );
	cache.set( 'Vegetable', 'Carrot' );
} ).catch( function( error ) { console.error( 'Failed to init cache:', error ); } );

.set(key, value)

Sets the value of a key in the cache.

cache.set( 'MyKey', 'MyValue' );

.get(key)

Gets the value of a key in the cache.

cache.get( 'MyKey' );

.pull()

Pulls the remote cache from the gist - overwrites local cache.

cache.pull().then( function() {
	// Do something.
} );

.push()

Pushes the local cache to the remote gist - overwrites the remote.

cache.push().then( function() {
	// Do something.
} );

Auto-push

ghks will automatically push the local cache to the Gist on certain events.

  • process SIGINT
  • process SIGTERM