You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					29 lines
				
				615 B
			
		
		
			
		
	
	
					29 lines
				
				615 B
			| 
											3 years ago
										 | 'use strict' | ||
|  | 
 | ||
|  | const EventEmitter = require('events').EventEmitter | ||
|  | const util = require('util') | ||
|  | 
 | ||
|  | function Store (storeMap = new Map()) { | ||
|  |   this.store = storeMap | ||
|  |   EventEmitter.call(this) | ||
|  | } | ||
|  | 
 | ||
|  | util.inherits(Store, EventEmitter) | ||
|  | 
 | ||
|  | Store.prototype.set = function set (sessionId, session, callback) { | ||
|  |   this.store.set(sessionId, session) | ||
|  |   callback() | ||
|  | } | ||
|  | 
 | ||
|  | Store.prototype.get = function get (sessionId, callback) { | ||
|  |   const session = this.store.get(sessionId) | ||
|  |   callback(null, session) | ||
|  | } | ||
|  | 
 | ||
|  | Store.prototype.destroy = function destroy (sessionId, callback) { | ||
|  |   this.store.delete(sessionId) | ||
|  |   callback() | ||
|  | } | ||
|  | 
 | ||
|  | module.exports = Store |