redis/client
Documentation
- source: redis/client.ts
Overview
Classes
Client
append()
Appends a value to the value of a key. If the key does not exist, it is created and set to the initial value.
tsappend(key: string, value: string): number;
Parameter Type Description keystringThe key to append to. valuestringThe value string to append. Returns
- Type:
number- Description: The length of the string after the append operation.
bitcount()
Counts the number of set bits (1s) in the string value of a key.
tsbitcount(key: string): number;
Parameter Type Description keystringThe key to perform the bitcount on. Returns
- Type:
number- Description: The number of set bits.
decr()
Decrements the number stored at key by one.
tsdecr(key: string): number;
Parameter Type Description keystringThe key holding the numeric value. Returns
- Type:
number- Description: The value of key after the decrement.
del()
Deletes the specified key.
tsdel(key: string): number;
Parameter Type Description keystringThe key to delete. Returns
- Type:
number- Description: The number of keys that were removed (1 if successful, 0 otherwise).
exists()
Checks if the specified key exists.
tsexists(key: string): boolean;
Parameter Type Description keystringThe key to check. Returns
- Type:
boolean- Description: True if the key exists, false otherwise.
get()
Gets the value of the specified key.
tsget(key: string): string;
Parameter Type Description keystringThe key to retrieve the value for. Returns
- Type:
string- Description: The value of the key, or null if the key does not exist.
incr()
Increments the number stored at key by one.
tsincr(key: string): number;
Parameter Type Description keystringThe key holding the numeric value. Returns
- Type:
number- Description: The value of key after the increment.
keys()
Finds all keys matching the given pattern.
tskeys(pattern: string): void;
Parameter Type Description patternstringThe pattern to match keys against (e.g., "user:*"). Returns
- Type:
void- Description: An array of matching keys.
set()
Sets the string value of a key.
tsset(key: string, value: string): string;
Parameter Type Description keystringThe key to set. valuestringThe string value to assign to the key. Returns
- Type:
string- Description: 'OK' on success.
lindex()
Gets an element from a list by its zero-based index.
tslindex(key: string, index: number): string;
Parameter Type Description keystringThe key of the list. indexnumberThe zero-based index (0 is the first element, -1 is the last). Returns
- Type:
string- Description: The element at the specified index, or null if the index is out of range.
llen()
Gets the length of the list stored at the key.
tsllen(key: string): number;
Parameter Type Description keystringThe key of the list. Returns
- Type:
number- Description: The length of the list.
lpop()
Removes and returns the first element of the list stored at the key (Left POP).
tslpop(key: string): string;
Parameter Type Description keystringThe key of the list. Returns
- Type:
string- Description: The first element of the list, or null when the list is empty.
lpush()
Inserts all specified values at the head of the list stored at the key (Left PUSH).
tslpush(key: string, value: any): any;
Parameter Type Description keystringThe key of the list. valueanyOne or more values to prepend to the list. Returns
- Type:
any- Description: The new length of the list.
lrange()
Returns the specified elements of the list stored at the key.
tslrange(key: string, start: number, stop: number): void;
Parameter Type Description keystringThe key of the list. startnumberThe starting zero-based offset. stopnumberThe stopping zero-based offset. Returns
- Type:
void- Description: An array of elements in the specified range.
rpop()
Removes and returns the last element of the list stored at the key (Right POP).
tsrpop(key: string): string;
Parameter Type Description keystringThe key of the list. Returns
- Type:
string- Description: The last element of the list, or null when the list is empty.
rpush()
Inserts all specified values at the tail of the list stored at the key (Right PUSH).
tsrpush(key: string, value: any): number;
Parameter Type Description keystringThe key of the list. valueanyOne or more values to append to the list. Returns
- Type:
number- Description: The new length of the list.
