4 * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
12 var crypto = require('crypto')
13 , Store = require('../store');
16 * Exports the constructor.
19 exports = module.exports = Memory;
20 Memory.Client = Client;
28 function Memory (opts) {
29 Store.call(this, opts);
33 * Inherits from Store.
36 Memory.prototype.__proto__ = Store.prototype;
39 * Publishes a message.
44 Memory.prototype.publish = function () { };
47 * Subscribes to a channel
52 Memory.prototype.subscribe = function () { };
60 Memory.prototype.unsubscribe = function () { };
69 Store.Client.apply(this, arguments);
74 * Inherits from Store.Client
77 Client.prototype.__proto__ = Store.Client;
85 Client.prototype.get = function (key, fn) {
86 fn(null, this.data[key] === undefined ? null : this.data[key]);
96 Client.prototype.set = function (key, value, fn) {
97 this.data[key] = value;
108 Client.prototype.has = function (key, fn) {
109 fn(null, key in this.data);
118 Client.prototype.del = function (key, fn) {
119 delete this.data[key];
125 * Destroys the client.
127 * @param {Number} number of seconds to expire data
131 Client.prototype.destroy = function (expiration) {
132 if ('number' != typeof expiration) {
137 setTimeout(function () {
139 }, expiration * 1000);