Home Reference Source Test Repository
import {Key} from 'webdismay/src/index.js'
public class | source

Key

Methods for manipulating a single key on the redis server

Constructor Summary

Public Constructor
public

Instantly create a key hander associated with a specific key, sends no requests to the server until a method is called.

Member Summary

Public Members
public

k: *

Method Summary

Public Methods
public

string append to the current value (via APPEND)

public

decrement integer key value by 1 and return decremented value (via DECR)

public

decrBy(amount: *): Promise<number, Error>

decrement integer key value by integer amount and return decremented value (via DECRBY)

public

delete key (via DEL)

public

check key existence (via EXISTS)

public

expire(seconds: *): Promise<number, Error>

set a delta timer for autodeletion (via EXPIRE) Untested.

public

expireAt(unixts: *): Promise<number, Error>

set a unix timestamp for autodeletion (not a JS timestamp, needs to be divided by 1000) (EXPIREAT) Untested.

public

get the current value (via GET)

public

getRange(starts: *, ends: *): Promise<string, Error>

return a substring of the current string value (via GETRANGE)

public

set a new value, return the previous value (via GETSET)

public

add 1 to the current value and return the new value (via INCR)

public

incrBy(amount: number): *

add integer amount to the current value and return the new value (via INCRBY)

public

incrByFloat(amount: number): *

add floating point amount to the curent value and return the new value (via INCRBYFLOAT)

public

moveToDB(db: *): *

public

pExpire(ms: *): *

public

pExpireAt(jsts: *): *

public

pSetEx(ms: *, v: *): *

public

pTTL(): *

public

persist(): *

public

rename key, potentially clobbering/overwriting key at new name (via RENAME)

public

set the value (via SET)

public

setEx(sec: *, v: *): *

public

overwrite string value with new value beginning at character offset

public

set the value only if the key is undefined (via SETNX)

public

get string length of value

public

ttl(): *

public

type(): *

Public Constructors

public constructor(k: string) source

Instantly create a key hander associated with a specific key, sends no requests to the server until a method is called. Includes methods for most redis commands for "Key" and "String"

Params:

NameTypeAttributeDescription
k string

Key

Public Members

public k: * source

Public Methods

public append(v: *): Promise<number, Error> source

string append to the current value (via APPEND)

Params:

NameTypeAttributeDescription
v *

Return:

Promise<number, Error>

response is string length of new value

public decr(): Promise<number, Error> source

decrement integer key value by 1 and return decremented value (via DECR)

Return:

Promise<number, Error>

response is new value after subtracting 1

public decrBy(amount: *): Promise<number, Error> source

decrement integer key value by integer amount and return decremented value (via DECRBY)

Params:

NameTypeAttributeDescription
amount *

Amount to subtract.

Return:

Promise<number, Error>

response is new value after subtracting amount

public del(): Promise<number, Error> source

delete key (via DEL)

Return:

Promise<number, Error>

response is 1 if key deleted, 0 if non-existent

public exists(): Promise<number, Error> source

check key existence (via EXISTS)

Return:

Promise<number, Error>

response is 1 if key exists, 0 if non-existent

public expire(seconds: *): Promise<number, Error> source

set a delta timer for autodeletion (via EXPIRE) Untested.

Params:

NameTypeAttributeDescription
seconds *

Seconds until auto-deletion, subject to redis expiration rules

Return:

Promise<number, Error>

response is 1 if timer was set, otherwise 0

public expireAt(unixts: *): Promise<number, Error> source

set a unix timestamp for autodeletion (not a JS timestamp, needs to be divided by 1000) (EXPIREAT) Untested.

Params:

NameTypeAttributeDescription
unixts *

Unix timetamp for autodeletion in seconds since Jan 1, 1970 00:00 UTC

Return:

Promise<number, Error>

response is 1 if timer was set, otherwise 0

public get(): Promise<string, Error> source

get the current value (via GET)

Return:

Promise<string, Error>

response is requested value

public getRange(starts: *, ends: *): Promise<string, Error> source

return a substring of the current string value (via GETRANGE)

Params:

NameTypeAttributeDescription
starts *
  • optional
  • default: 0

beginning index (0 is beginning)

ends *
  • optional
  • default: -1

ending index (-1 is end of string)

Return:

Promise<string, Error>

response is requested substring

public getSet(v: *): Promise<string, Error> source

set a new value, return the previous value (via GETSET)

Params:

NameTypeAttributeDescription
v *

new value

Return:

Promise<string, Error>

response is previous value

public incr(): Promise<number, Error> source

add 1 to the current value and return the new value (via INCR)

Return:

Promise<number, Error>

response is new value

public incrBy(amount: number): * source

add integer amount to the current value and return the new value (via INCRBY)

Params:

NameTypeAttributeDescription
amount number

Integer amount to add

Return:

*

public incrByFloat(amount: number): * source

add floating point amount to the curent value and return the new value (via INCRBYFLOAT)

Params:

NameTypeAttributeDescription
amount number

Floating point amount to add

Return:

*

public moveToDB(db: *): * source

Params:

NameTypeAttributeDescription
db *

Return:

*

public pExpire(ms: *): * source

Params:

NameTypeAttributeDescription
ms *

Return:

*

public pExpireAt(jsts: *): * source

Params:

NameTypeAttributeDescription
jsts *

Return:

*

public pSetEx(ms: *, v: *): * source

Params:

NameTypeAttributeDescription
ms *
v *

Return:

*

public pTTL(): * source

Return:

*

public persist(): * source

Return:

*

public rename(newk: string): Promise<Array, Error> source

rename key, potentially clobbering/overwriting key at new name (via RENAME)

Params:

NameTypeAttributeDescription
newk string

new key

Return:

Promise<Array, Error>

status response

public set(v: string): Promise<Array, Error> source

set the value (via SET)

Params:

NameTypeAttributeDescription
v string

New value

Return:

Promise<Array, Error>

status return

public setEx(sec: *, v: *): * source

Params:

NameTypeAttributeDescription
sec *
v *

Return:

*

public setRange(offset: number): Promise<number, Error> source

overwrite string value with new value beginning at character offset

Params:

NameTypeAttributeDescription
offset number

Offset, where 0 is beginning of string

Return:

Promise<number, Error>

response is string length of new value

public setnx(v: *): Promise<number, Error> source

set the value only if the key is undefined (via SETNX)

Params:

NameTypeAttributeDescription
v *

Value to set if key is undefined

Return:

Promise<number, Error>

response is 1 if they key was undefined and the new value was set, 0 if the key was defined and the new vale not set

public strlen(): Promise<number, Error> source

get string length of value

Return:

Promise<number, Error>

response is string length of value

public ttl(): * source

Return:

*

public type(): * source

Return:

*