@salutejs/storage-adapter-memory
Advanced tools
Comparing version 0.41.0 to 0.42.0-canary.117.7110907139.0
import { SaluteSession, SaluteSessionStorage } from '@salutejs/scenario'; | ||
export declare class SaluteMemoryStorage implements SaluteSessionStorage { | ||
private sessions; | ||
private lifetime; | ||
constructor({ lifetime }?: { | ||
lifetime?: number; | ||
}); | ||
resolve(id: string): Promise<SaluteSession>; | ||
save({ id, session, lifetime }: { | ||
save({ id, session }: { | ||
id: string; | ||
session: SaluteSession; | ||
lifetime?: number; | ||
}): Promise<void>; | ||
@@ -10,0 +13,0 @@ reset(id: string): Promise<void>; |
@@ -41,4 +41,7 @@ "use strict"; | ||
var SaluteMemoryStorage = /** @class */ (function () { | ||
function SaluteMemoryStorage() { | ||
function SaluteMemoryStorage(_a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.lifetime, lifetime = _c === void 0 ? 60 * 60 * 1000 : _c; | ||
this.sessions = {}; | ||
this.lifetime = lifetime; | ||
setInterval(this.validate, 60 * 1000); | ||
} | ||
@@ -58,8 +61,8 @@ SaluteMemoryStorage.prototype.resolve = function (id) { | ||
SaluteMemoryStorage.prototype.save = function (_a) { | ||
var id = _a.id, session = _a.session, _b = _a.lifetime, lifetime = _b === void 0 ? 0 : _b; | ||
var id = _a.id, session = _a.session; | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_c) { | ||
return __generator(this, function (_b) { | ||
this.sessions[id] = session; | ||
if (lifetime > 0) { | ||
this.sessions[id].expires = Date.now() + lifetime; | ||
if (this.lifetime > 0) { | ||
this.sessions[id].expires = Date.now() + this.lifetime; | ||
} | ||
@@ -78,2 +81,3 @@ return [2 /*return*/, Promise.resolve()]; | ||
state: {}, | ||
expires: this.lifetime > 0 ? Date.now() + this.lifetime : undefined, | ||
}; | ||
@@ -80,0 +84,0 @@ return [2 /*return*/, Promise.resolve()]; |
{ | ||
"name": "@salutejs/storage-adapter-memory", | ||
"version": "0.41.0", | ||
"version": "0.42.0-canary.117.7110907139.0", | ||
"description": "In memory storage adapter for SaluteJS", | ||
@@ -32,5 +32,5 @@ "author": "Salute Frontend Team <salute.developers@gmail.com>", | ||
"dependencies": { | ||
"@salutejs/scenario": "0.41.0" | ||
"@salutejs/scenario": "0.42.0-canary.117.7110907139.0" | ||
}, | ||
"gitHead": "54a55a1c44b1e3da22b10efef6a34794e463efe1" | ||
"gitHead": "93cdcf2520ce1cbcdeeae3fe1a6fce53dc0a634f" | ||
} |
Sorry, the diff of this file is not supported yet
8051
116
+ Added@salutejs/scenario@0.42.0-canary.117.7110907139.0(transitive)
- Removed@salutejs/scenario@0.41.0(transitive)