caccl-memory-store
Advanced tools
Comparing version 2.0.0-beta.1 to 2.0.0-beta.2
import CACCLStore from './CACCLStore'; | ||
import CACCLStoreValue from './CACCLStoreValue'; | ||
declare class CACCLMemoryStore implements CACCLStore { | ||
@@ -24,3 +25,3 @@ private primaryStore; | ||
*/ | ||
get(key: string): Promise<object | undefined>; | ||
get(key: string): Promise<CACCLStoreValue | undefined>; | ||
/** | ||
@@ -33,4 +34,4 @@ * Add/overwrite an entry in the store | ||
*/ | ||
set(key: string, value: object): Promise<object | undefined>; | ||
set(key: string, value: CACCLStoreValue): Promise<CACCLStoreValue | undefined>; | ||
} | ||
export default CACCLMemoryStore; |
@@ -0,1 +1,2 @@ | ||
import CACCLStoreValue from './CACCLStoreValue'; | ||
interface CACCLStore { | ||
@@ -7,3 +8,3 @@ /** | ||
*/ | ||
get(key: string): Promise<object | undefined>; | ||
get(key: string): Promise<CACCLStoreValue | undefined>; | ||
/** | ||
@@ -15,4 +16,4 @@ * Store | ||
*/ | ||
set(key: string, value: object): Promise<object | undefined>; | ||
set(key: string, value: CACCLStoreValue): Promise<CACCLStoreValue | undefined>; | ||
} | ||
export default CACCLStore; |
{ | ||
"name": "caccl-memory-store", | ||
"version": "2.0.0-beta.1", | ||
"version": "2.0.0-beta.2", | ||
"description": "CACCL's memory store for credential storage and caching", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -6,6 +6,7 @@ // Import libs | ||
import CACCLStore from './CACCLStore'; | ||
import CACCLStoreValue from './CACCLStoreValue'; | ||
class CACCLMemoryStore implements CACCLStore { | ||
private primaryStore: Map<string, object>; | ||
private secondaryStore: Map<string, object>; | ||
private primaryStore: Map<string, CACCLStoreValue>; | ||
private secondaryStore: Map<string, CACCLStoreValue>; | ||
private mutex: locks.Mutex; | ||
@@ -21,4 +22,4 @@ | ||
// Initialize state | ||
this.primaryStore = new Map<string, object>(); | ||
this.secondaryStore = new Map<string, object>(); | ||
this.primaryStore = new Map<string, CACCLStoreValue>(); | ||
this.secondaryStore = new Map<string, CACCLStoreValue>(); | ||
this.mutex = locks.createMutex(); | ||
@@ -44,4 +45,4 @@ | ||
this.mutex.lock(() => { | ||
this.secondaryStore = new Map<string, object>(this.primaryStore); | ||
this.primaryStore = new Map<string, object>(); | ||
this.secondaryStore = new Map<string, CACCLStoreValue>(this.primaryStore); | ||
this.primaryStore = new Map<string, CACCLStoreValue>(); | ||
this.mutex.unlock(); | ||
@@ -57,3 +58,3 @@ }); | ||
*/ | ||
public async get(key: string): Promise<object | undefined> { | ||
public async get(key: string): Promise<CACCLStoreValue | undefined> { | ||
// Look up in either store | ||
@@ -74,3 +75,3 @@ return ( | ||
*/ | ||
public async set(key: string, value: object): Promise<object | undefined> { | ||
public async set(key: string, value: CACCLStoreValue): Promise<CACCLStoreValue | undefined> { | ||
return new Promise((resolve) => { | ||
@@ -77,0 +78,0 @@ // Set in primary store |
@@ -0,1 +1,3 @@ | ||
import CACCLStoreValue from './CACCLStoreValue'; | ||
interface CACCLStore { | ||
@@ -7,3 +9,3 @@ /** | ||
*/ | ||
get(key: string): Promise<object | undefined>; | ||
get(key: string): Promise<CACCLStoreValue | undefined>; | ||
@@ -16,5 +18,5 @@ /** | ||
*/ | ||
set(key: string, value: object): Promise<object | undefined>; | ||
set(key: string, value: CACCLStoreValue): Promise<CACCLStoreValue | undefined>; | ||
} | ||
export default CACCLStore; |
Sorry, the diff of this file is not supported yet
20005
24
396