Skip to content

GAWMiners/clache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
Name Type(s) Description
opts Object The 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
Name Type(s) Description
key String The key
work Function The work function
cb Function function(err, res)

clache.set()

Set val for the given key

Params
Name Type(s) Description
key String The key
val String, Number, Boolean, Array, Object The value
cb Function function(err, res)

clache.setex()

Set val for the given key with ttl

Params
Name Type(s) Description
key String The key
ttl Number The ttl
val String, Number, Boolean, Array, Object The value
cb Function function(err, res)

clache.get()

Get the value for the given key

Params
Name Type(s) Description
key String The key
cb Function function(err, res)

clache.del()

Deletes the value for the given key

Params
Name Type(s) Description
key String The key
cb Function function(err, res)

About

pooled redis caching made easy

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors