1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- exports = module.exports = Store;
- var EventEmitter = process.EventEmitter;
- function Store (options) {
- this.options = options;
- this.clients = {};
- };
- Store.prototype.__proto__ = EventEmitter.prototype;
- Store.prototype.client = function (id) {
- if (!this.clients[id]) {
- this.clients[id] = new (this.constructor.Client)(this, id);
- }
- return this.clients[id];
- };
- Store.prototype.destroyClient = function (id, expiration) {
- if (this.clients[id]) {
- this.clients[id].destroy(expiration);
- delete this.clients[id];
- }
- return this;
- };
- Store.prototype.destroy = function (clientExpiration) {
- var keys = Object.keys(this.clients)
- , count = keys.length;
- for (var i = 0, l = count; i < l; i++) {
- this.destroyClient(keys[i], clientExpiration);
- }
- this.clients = {};
- return this;
- };
- Store.Client = function (store, id) {
- this.store = store;
- this.id = id;
- };
|