redis-typescript
Version:
redis client for node.js with typescript and async
112 lines • 4.2 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const base_1 = require("../core/base");
var MethodKey;
(function (MethodKey) {
MethodKey["del"] = "DEL";
MethodKey["dump"] = "DUMP";
MethodKey["exists"] = "EXISTS";
MethodKey["expire"] = "EXPIRE";
MethodKey["expireat"] = "EXPIREAT";
MethodKey["pexpire"] = "PEXPIRE";
MethodKey["pexpireat"] = "PEXPIREAT";
MethodKey["keys"] = "KEYS";
MethodKey["move"] = "MOVE";
MethodKey["persist"] = "PERSIST";
MethodKey["pttl"] = "PTTL";
MethodKey["ttl"] = "TTL";
MethodKey["randomkey"] = "RANDOMKEY";
MethodKey["rename"] = "RENAME";
MethodKey["renamenx"] = "RENAMENX";
MethodKey["type"] = "TYPE";
})(MethodKey || (MethodKey = {}));
class RedisKey extends base_1.Base {
del(key, ...keys) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.command(MethodKey.del, key, ...keys));
});
}
// public async dump(key: string) {
// return (await this.command(MethodKey.dump, key)) as string | null;
// }
exists(key, ...keys) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.command(MethodKey.exists, key, ...keys));
});
}
expire(key, seconds) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.command(MethodKey.expire, key, seconds));
});
}
expireat(key, timestamp) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.command(MethodKey.expireat, key, timestamp));
});
}
keys(pattern) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.command(MethodKey.keys, pattern));
});
}
move(key, db) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.command(MethodKey.move, key, db));
});
}
persist(key) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.command(MethodKey.persist, key));
});
}
pexpire(key, milliseconds) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.command(MethodKey.pexpire, key, milliseconds));
});
}
pexpireat(key, millisecondsTimestamp) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.command(MethodKey.pexpireat, key, millisecondsTimestamp));
});
}
pttl(key) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.command(MethodKey.pttl, key));
});
}
randomkey() {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.command(MethodKey.randomkey));
});
}
rename(key, newKey) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.command(MethodKey.rename, key, newKey));
});
}
renamenx(key, newKey) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.command(MethodKey.renamenx, key, newKey));
});
}
ttl(key) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.command(MethodKey.ttl, key));
});
}
type(key) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.command(MethodKey.type, key));
});
}
}
exports.RedisKey = RedisKey;
//# sourceMappingURL=key.js.map