-
Notifications
You must be signed in to change notification settings - Fork 0
/
memcache.js
40 lines (30 loc) · 862 Bytes
/
memcache.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict'
var merge = require('./utils').merge;
// use es6 Map
function MemoryCache () {
this._cache = new Map();
}
MemoryCache.prototype.get = function(key) {
return this._cache.get(key);
}
MemoryCache.prototype.set = function(key, val) {
this._cache.set(key, val);
}
// memory cache ignore ns param
MemoryCache.prototype.hget = function(ns, key) {
return this._cache.get(key);
}
MemoryCache.prototype.hset = function(ns, key, val) {
this._cache.set(key, val);
}
MemoryCache.prototype.update = function(key, val) {
let ov = this._cache.get(key);
this._cache.set(key, merge(ov || {}, val));
}
MemoryCache.prototype.hupdate = function(ns, key, val) {
let ov = this._cache.get(key);
this._cache.set(key, merge(ov || {}, val));
}
MemoryCache.prototype.end = MemoryCache.prototype.quit = function() {
}
module.exports = MemoryCache