chen-redis
Version:
Redis for Chen Framework
176 lines (175 loc) • 5.46 kB
TypeScript
import { KeyValuePair } from 'chen/core';
import { RedisConfig } from './index';
/**
* RedisConnection class
*/
export declare class RedisConnection {
private config;
/**
* Redis client
* @type {redis.RedisClient}
*/
private client;
/**
* Redis configuration
* @param {RedisConfig} private config
*/
constructor(config: RedisConfig);
/**
* Get redis client
* @return {redis.RedisClient}
*/
private getClient();
/**
* Execute redis command
* @param {string} command
* @param {any[]} ...args
* @return {Promise<U>}
*/
private executeCommand<U>(command, ...args);
/**
* Set the value of key
* @param {string} key
* @param {any} value
* @return {Promise<string>}
*/
set(key: string, value: any): Promise<string>;
/**
* Get the value of key
* @param {string} key
* @return {Promise<string>}
*/
get(key: string): Promise<string>;
/**
* Returns all keys matching pattern.
* @param {string match
* @return {Promise<any[]>}
*/
keys(match: string): Promise<any[]>;
/**
* Returns the length of the list stored at key
* @param {string} key
* @return {Promise<number>}
*/
llen(key: string): Promise<number>;
/**
* Returns all fields and values of the hash stored at key
* @param {string} key
* @return {Promise<KeyValuePair<any>>}
*/
hgetall(key: string): Promise<KeyValuePair<any>>;
/**
* Sets the specified fields to their respective values in the hash stored at key
* @param {string} key
* @param {KeyValuePair<any>} values
* @return {Promise<boolean>}
*/
hmset(key: string, values: KeyValuePair<any>): Promise<boolean>;
/**
* Sets field in the hash stored at key to value
* @param {string} key
* @param {string} field
* @param {any} value
* @return {Promise<number>}
*/
hset(key: string, field: string, value: any): Promise<number>;
/**
* Returns the value associated with field in the hash stored at key.
* @param {string} key
* @param {string} field
* @return {Promise<string>}
*/
hget(key: string, field: string): Promise<string>;
/**
* Returns if key exists
* @param {string | string[]} key
* @return {Promise<number>}
*/
exists(key: string | string[]): Promise<number>;
/**
* Removes the specified keys
* @param {string | string[]} key
* @return {Promise<number>}
*/
del(key: string | string[]): Promise<number>;
/**
* Returns the specified elements of the list stored at key
* @param {string} key
* @param {number} start
* @param {number} stop
* @return {Promise<any[]>}
*/
lrange(key: string, start: number, stop: number): Promise<any[]>;
/**
* Removes and returns the first element of the list stored at key
* @param {string} key
* @return {Promise<string>}
*/
lpop(key: string): Promise<string>;
/**
* Insert all the specified values at the tail of the list stored at key
* @param {string} key
* @param {any | any[]} values
* @return {Promise<number>}
*/
rpush(key: string, values: any | any[]): Promise<number>;
/**
* Insert all the specified values at the head of the list stored at key
* @param {string} key
* @param {any | any[]} values
* @return {Promise<number>}
*/
lpush(key: string, values: any | any[]): Promise<number>;
/**
* Returns the score of member in the sorted set at key
* @param {string} key
* @param {string} value
* @return {Promise<string>}
*/
zscore(key: string, value: string): Promise<string>;
/**
* Adds all the specified members with the specified scores to the sorted set stored at key
* @param {string} key
* @param {number} score
* @param {string} value
* @param {string = ''} option
* @return {Promise<number>}
*/
zadd(key: string, score: number, value: string, option?: string): Promise<number>;
/**
* Returns the specified range of elements in the sorted set stored at key
* @param {string} key
* @param {number} start
* @param {number} stop
* @param {boolean = false} withScores
* @return {Promise<any[]>}
*/
zrevrange(key: string, start: number, stop: number, withScores?: boolean): Promise<any[]>;
/**
* Returns the specified range of elements in the sorted set stored at key
* @param {string} key
* @param {number} start
* @param {number} stop
* @param {boolean = false} withScores
* @return {Promise<any[]>}
*/
zrange(key: string, start: number, stop: number, withScores?: boolean): Promise<any[]>;
/**
* Returns the sorted set cardinality (number of elements) of the sorted set stored at key
* @param {string} key
* @return {Promise<number>}
*/
zcard(key: string): Promise<number>;
/**
* Removes the specified members from the sorted set stored at key
* @param {string} key
* @param {string} value
* @return {Promise<number>}
*/
zrem(key: string, value: string): Promise<number>;
/**
* Delete all keys of current selected DB
* @return {Promise<string>}
*/
flushdb(): Promise<string>;
}