4 * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
9 * Expose the constructor.
12 exports = module.exports = Store;
15 * Module dependencies.
18 var EventEmitter = process.EventEmitter;
26 function Store (options) {
27 this.options = options;
32 * Inherit from EventEmitter.
35 Store.prototype.__proto__ = EventEmitter.prototype;
38 * Initializes a client store
44 Store.prototype.client = function (id) {
45 if (!this.clients[id]) {
46 this.clients[id] = new (this.constructor.Client)(this, id);
49 return this.clients[id];
56 * @param {Number} number of seconds to expire client data
60 Store.prototype.destroyClient = function (id, expiration) {
61 if (this.clients[id]) {
62 this.clients[id].destroy(expiration);
63 delete this.clients[id];
72 * @param {Number} number of seconds to expire client data
76 Store.prototype.destroy = function (clientExpiration) {
77 var keys = Object.keys(this.clients)
78 , count = keys.length;
80 for (var i = 0, l = count; i < l; i++) {
81 this.destroyClient(keys[i], clientExpiration);
95 Store.Client = function (store, id) {