API: client
Source:
redis/client.ts
Redis Client
This class serves as a facade for common Redis operations, providing a convenient JavaScript interface that wraps the underlying Java Redis client implementation.
Usage
import { client } from "sdk/redis";
import { response } from "sdk/http";
const redisClient = client.getClient();
redisClient.set("foo", "bar");
const data = redisClient.get("foo");
response.println(data);Classes
Client
Redis Client
This class serves as a facade for common Redis operations, providing a convenient
JavaScript interface that wraps the underlying Java Redis client implementation.
Methods
append
append (key:string, value:string):numberAppends a value to the value of a key. If the key does not exist,
it is created and set to the initial value.
@param key The key to append to.
@param value The value string to append.
@returns The length of the string after the append operation.
bitcount
bitcount (key:string):numberCounts the number of set bits (1s) in the string value of a key.
@param key The key to perform the bitcount on.
@returns The number of set bits.
decr
decr (key:string):numberDecrements the number stored at key by one.
@param key The key holding the numeric value.
@returns The value of key after the decrement.
del
del (key:string):numberDeletes the specified key.
@param key The key to delete.
@returns The number of keys that were removed (1 if successful, 0 otherwise).
exists
exists (key:string):booleanChecks if the specified key exists.
@param key The key to check.
@returns True if the key exists, false otherwise.
get
get (key:string):stringGets the value of the specified key.
@param key The key to retrieve the value for.
@returns The value of the key, or null if the key does not exist.
incr
incr (key:string):numberIncrements the number stored at key by one.
@param key The key holding the numeric value.
@returns The value of key after the increment.
keys
keys (pattern:string):string[]Finds all keys matching the given pattern.
@param pattern The pattern to match keys against (e.g., "user:*").
@returns An array of matching keys.
set
set (key:string, value:string):stringSets the string value of a key.
@param key The key to set.
@param value The string value to assign to the key.
@returns 'OK' on success.
lindex
lindex (key:string, index:number):stringGets an element from a list by its zero-based index.
@param key The key of the list.
@param index The zero-based index (0 is the first element, -1 is the last).
@returns The element at the specified index, or null if the index is out of range.
llen
llen (key:string):numberGets the length of the list stored at the key.
@param key The key of the list.
@returns The length of the list.
lpop
lpop (key:string):stringRemoves and returns the first element of the list stored at the key (Left POP).
@param key The key of the list.
@returns The first element of the list, or null when the list is empty.
lpush
lpush (key:string, ...value:string[]):string[])Inserts all specified values at the head of the list stored at the key (Left PUSH).
@param key The key of the list.
@param value One or more values to prepend to the list.
@returns The new length of the list.
lrange
lrange (key:string, start:number, stop:number):string[]Returns the specified elements of the list stored at the key.
@param key The key of the list.
@param start The starting zero-based offset.
@param stop The stopping zero-based offset.
@returns An array of elements in the specified range.
rpop
rpop (key:string):stringRemoves and returns the last element of the list stored at the key (Right POP).
@param key The key of the list.
@returns The last element of the list, or null when the list is empty.
rpush
rpush (key:string, ...value:string[]):numberInserts all specified values at the tail of the list stored at the key (Right PUSH).
@param key The key of the list.
@param value One or more values to append to the list.
@returns The new length of the list.