1.0.4 • Published 4 years ago

ncached v1.0.4

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

NCached

NCached is a Memcached-compatible server written in node.js

Installation

Install globally using npm:

npm i -g ncached

Usage

Start the server from the command line:

ncached

Server options

FlagDescriptionDefault value
-pPort where the server will listen for new clients11212
-lLogger level. Available options: error, info, verbose, debuginfo

Available commands

Retrieval commands:

  • get
  • gets

Storage commands:

  • set
  • add
  • replace
  • append
  • prepend
  • cas

To learn more about how memcached commands work, have a look at this guide

Client examples

Telnet

Connect to an NCached server via telnet:

telnet <server_ip> <server_port>

You can store and retrieve data just as with a normal memcached server:

set foo 0 20 3
bar

And then:

get foo

Will return:

VALUE foo 0 3
bar
END

Memcached client for node

Using memcached library:

const Memcached = require('memcached')
const memcached = new Memcached('localhost:11212')

memcached.set('foo', 'bar', 20, (err) => { 
  // you can use 'gets' command to retrieve the cas_token
  memcached.gets('foo', (err, data) => {
    // change value with 'cas' command
    memcached.cas('foo', 'redis', data.cas, 20, err => { /* stuff */ })
  })
})

Run tests

Go to installation folder and run:

npm run test