UNPKG

dt-common-device

Version:

A secure and robust device management library for IoT applications

69 lines (68 loc) 2.27 kB
export declare class RedisUtils { private readonly client; /** * Get a value from Redis * @param key - The key to get * @param field - The field to get * @returns The value */ hget(key: string, field: string): Promise<any>; /** * Set a value in Redis with a TTL * @param key - The key to set * @param field - The field to set * @param value - The value to set (JSON stringified) * @param ttl - The TTL in seconds * @returns The number of fields set */ hsetWithTTL(key: string, field: string, value: string, ttl: number): Promise<number>; /** * Set a value in Redis * @param key - The key to set * @param field - The field to set * @param value - The value to set (JSON stringified) * @returns The number of fields set */ hset(key: string, field: string, value: string): Promise<number>; /** * Delete a field from a hash * @param key - The key to delete from * @param fields - The fields to delete * @returns The number of fields deleted */ hdel(key: string, ...fields: string[]): Promise<number>; /** * Set a value in Redis with a TTL * @param key - The key to set * @param value - The value to set (JSON stringified) * @param ttl - The TTL in seconds * @returns The value */ set(key: string, value: string, ttl: number): Promise<string>; /** * Get a value from Redis * @param key - The key to get * @returns The value */ get(key: string): Promise<string | null>; /** * Delete a key from Redis * @param key - The key to delete * @returns The number of keys deleted */ del(key: string): Promise<number>; /** * Check if a key exists * @param key - The key to check * @returns 1 if the key exists, 0 otherwise */ exists(key: string): Promise<number>; /** * Set an expiration time for a key * @param key - The key to set the expiration for * @param seconds - The number of seconds until the key expires * @returns 1 if the expiration was set, 0 if the key does not exist */ expire(key: string, seconds: number): Promise<any>; hgetAll(key: string): Promise<any>; }