mobiletto 1.0.47 → 1.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/util/redis.js +16 -10
package/package.json
CHANGED
package/util/redis.js
CHANGED
|
@@ -49,10 +49,16 @@ class MobilettoCache {
|
|
|
49
49
|
this.redis = null
|
|
50
50
|
}
|
|
51
51
|
this.prefix = prefix
|
|
52
|
-
this.
|
|
53
|
-
|
|
54
|
-
(
|
|
55
|
-
|
|
52
|
+
if (this.redis) {
|
|
53
|
+
// test connection by flushing
|
|
54
|
+
this.flush().then(
|
|
55
|
+
() => { logger.debug(`redis(${name}): successfully flushed`) },
|
|
56
|
+
(e) => {
|
|
57
|
+
logger.error(`redis(${name}): error flushing: ${e}, not using redis!`)
|
|
58
|
+
this.redis = null
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
}
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
stats = () => this.counters
|
|
@@ -81,11 +87,11 @@ class MobilettoCache {
|
|
|
81
87
|
}
|
|
82
88
|
}
|
|
83
89
|
|
|
84
|
-
get = key => {
|
|
90
|
+
get = async key => {
|
|
85
91
|
this.counters.get++
|
|
86
|
-
logger.
|
|
87
|
-
const val = this.doRedis(r => r.get(this.pfx(key)), null)
|
|
88
|
-
logger.
|
|
92
|
+
logger.silly(`redis(${this.name}): get(${key}) starting`)
|
|
93
|
+
const val = await this.doRedis(r => r.get(this.pfx(key)), null)
|
|
94
|
+
logger.silly(`redis(${this.name}): get(${key}) found value: ${val}`)
|
|
89
95
|
if (val) {
|
|
90
96
|
this.counters.hit++
|
|
91
97
|
} else {
|
|
@@ -100,9 +106,9 @@ class MobilettoCache {
|
|
|
100
106
|
|
|
101
107
|
set = async (key, val, expirationMillis = DEFAULT_EXPIRATION_MILLIS) => {
|
|
102
108
|
this.counters.set++
|
|
103
|
-
logger.
|
|
109
|
+
logger.silly(`redis(${this.name}): set(${key}, ${val}, ${expirationMillis}) starting`)
|
|
104
110
|
await this.doRedisAsync(r => r.set(this.pfx(key), val, 'EX', expirationMillis / 1000))
|
|
105
|
-
logger.
|
|
111
|
+
logger.silly(`redis(${this.name}): set(${key}, ${val}, ${expirationMillis}) finished`)
|
|
106
112
|
}
|
|
107
113
|
|
|
108
114
|
del = async key => {
|