0.2.0 • Published 10 years ago

clache v0.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

clache

Build Status Coverage Status

Author

Evan Lucas

License

MIT

Installation

$ npm install --save clache

Tests

$ npm test

Coverage

$ npm run cover

API

clache()

Contructor

Example

var opts = {
  ttl: 100 // in seconds
, host: '127.0.0.1'
, port: 6379
, password: null
}
var cache = new clache(opts)
Params
NameType(s)Description
optsObjectThe options object

clache.wrap()

Wrap an asynchronous function and cache it

Example

function find(cb) {
  return cb(null, { id: 1, name: 'evan' })
}

var id = '1234'
clache.wrap('user_'+id, find, function(err, results) {
  if (err) throw err
  console.log(results)
})
Params
NameType(s)Description
keyStringThe key
workFunctionThe work function
cbFunctionfunction(err, res)

clache.set()

Set val for the given key

Params
NameType(s)Description
keyStringThe key
valString, Number, Boolean, Array, ObjectThe value
cbFunctionfunction(err, res)

clache.setex()

Set val for the given key with ttl

Params
NameType(s)Description
keyStringThe key
ttlNumberThe ttl
valString, Number, Boolean, Array, ObjectThe value
cbFunctionfunction(err, res)

clache.get()

Get the value for the given key

Params
NameType(s)Description
keyStringThe key
cbFunctionfunction(err, res)

clache.del()

Deletes the value for the given key

Params
NameType(s)Description
keyStringThe key
cbFunctionfunction(err, res)

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago