"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MemoryCacheClient = void 0;
var MemoryCacheClient = (function () {
    function MemoryCacheClient() {
        this.cache = new Map();
    }
    MemoryCacheClient.prototype.get = function (key) {
        var _this = this;
        return new Promise(function (resolve) {
            var entry = _this.cache.get(key);
            if (entry === undefined)
                return resolve(null);
            if (entry.expiresAt && entry.expiresAt < Date.now()) {
                _this.cache.delete(key);
                return resolve(null);
            }
            resolve(entry.value);
        });
    };
    MemoryCacheClient.prototype.set = function (key, value, ttl) {
        var _this = this;
        return new Promise(function (resolve) {
            var expiresAt = ttl ? Date.now() + ttl * 1000 : null;
            _this.cache.set(key, { value: value, expiresAt: expiresAt });
            resolve(key);
        });
    };
    MemoryCacheClient.prototype.sub = function (_topic, _callback) {
        return Promise.resolve(1);
    };
    MemoryCacheClient.prototype.pub = function (_topic, _message) {
        return Promise.resolve(1);
    };
    return MemoryCacheClient;
}());
exports.MemoryCacheClient = MemoryCacheClient;
//# sourceMappingURL=MemoryCacheClient.js.map