Simple module to manipulate PHP session vars ($_SESSION) stored in JSON, using memcached
CAREFUL: this is NEW version of memcache !
Important: This package is NOT backward compatible with 0.1.x versions... Be careful if you update your npm project...
Install with npm:
npm install phpsession
Require the module:
PHPSESSION = require 'phpsession'
Instantiate:
sess = new PHPSESSION()
sess.connect
host: 127.0.0.1 # Default value
port: 11211 # Default value
if sess.isConnected()
console.log 'All right !!'
sess.get
id: '9eir0ul21knvmlhu0a4kleh8j1'
,(data) -> console.log data
sess.set
id: '9eir0ul21knvmlhu0a4kleh8j1'
data: { 'hello': 'world' }
lifetime: 1440
sess.replace
id: '9eir0ul21knvmlhu0a4kleh8j1'
data: { 'hello': 'world' }
lifetime: 1440
sess.refresh
id: '9eir0ul21knvmlhu0a4kleh8j1'
lifetime: 1440
sess.update
id: '9eir0ul21knvmlhu0a4kleh8j1'
key: 'hello'
value: 'better world'
lifetime: 1440
sess.delete
id: '9eir0ul21knvmlhu0a4kleh8j1'
All methods supports callback parameters:
sess.set
id: '9eir0ul21knvmlhu0a4kleh8j1'
data: { 'hello': 'better world' }
, (res) ->
console.log "Received: #{res}"
# Do something with result...
You can run unit-tests using mocha with:
npm test