Compare commits

...

2 Commits

Author SHA1 Message Date
Taylor McKinnon 954a0cc5a3 fix CacheClient.pushMetric to `await` this._cacheBackend.addToShard 2022-05-06 11:25:11 -07:00
Taylor McKinnon ba07ad48ac wait for ready before returning RedisCache.connect() 2022-05-06 11:24:14 -07:00
2 changed files with 4 additions and 2 deletions

View File

@ -19,7 +19,9 @@ class RedisCache {
moduleLogger.debug('Connecting to redis...');
this._redis = new RedisClient(this._options);
this._redis.connect();
return true;
return new Promise(resolve => {
this._redis.once('ready', () => resolve(true));
});
}
async disconnect() {

View File

@ -23,7 +23,7 @@ class CacheClient {
async pushMetric(metric) {
const shard = shardFromTimestamp(metric.timestamp);
if (!this._cacheBackend.addToShard(shard, metric)) {
if (!(await this._cacheBackend.addToShard(shard, metric))) {
return false;
}
await this._counterBackend.updateCounters(metric);