Function
Static Public Summary | ||
public |
checkStatus(response,: Object): Object Check for 2xx response.status after fetch; used by request() |
|
public |
set common options for all webdis/redis requests |
|
public |
deletes keys on the redis server (via DEL) |
|
public |
echo message |
|
public |
Convenience function equivalent to new Hash(k) |
|
public |
Convenience function equivalent to new Key(k) to save typing "new" over and over |
|
public |
keysMatching(pattern: String): Promise<string[], Error> lists all keys or keys matching a pattern (via KEYS) |
|
public |
convenience function equivalent to new List(k) to keep from typing "new" all the time |
|
public |
read multiple redis keys via MGET |
|
public |
set multiple redis keys from javascript object via MSET |
|
public |
set multiple redis keys if and only if none of the keys exist; sets all of the keys or none (via MSETNX) |
|
public |
return an existing key at random (via RANDOMKEY) |
|
public |
send a command array to webdis, return a Promise of a javascript object response. |
|
public |
Convenience function equivalent to new Rset(k), to avoid typing "new" over and over |
|
public |
select which redis database to use for this connection (via SELECT). |
|
public |
Pass non-objects unaltered, JSON.stringify objects/arrays. |
|
public |
JSON.parse stringified response into objects, pass unparseable content as is. |
Static Public
public checkStatus(response,: Object): Object source
import {checkStatus} from 'webdismay/src/index.js'
Check for 2xx response.status after fetch; used by request()
Params:
Name | Type | Attribute | Description |
response, | Object | presumably from fetch.then() |
Throw:
with response.statusText if not 2xx |
public configure(o: Object): Object source
import {configure} from 'webdismay/src/index.js'
set common options for all webdis/redis requests
Params:
Name | Type | Attribute | Description |
o | Object | configuration options |
|
o.method | string |
|
request HTTP method may be set to GET or POST. Some test frameworks (e.g.karma) seem to have difficulty proxying POST and need GET. POST is recommended for production to avoid cache issues. |
o.endPoint | string |
|
fetch URL where webdis is listening for requests |
o.credentials | string |
|
fetch option determining whether to send http-auth or other credentials with each request |
o.headers | Object |
|
fetch option setting headers (e.g. accept, content-type) for each fetch. Default sets headers for 'application/json' |
o.preProcess | function(cmdAndParams: Array): string |
|
function to determine a URL-like string representing an array containing a redis command string and parameters. |
o.postProcess | function(response: Object): Object |
|
function to transform response objects received by fetch, after transforming to JSON and dereferencing webdis object return |
public del(keys: ...string): Promise<number, Error> source
import {del} from 'webdismay/src/index.js'
deletes keys on the redis server (via DEL)
Params:
Name | Type | Attribute | Description |
keys | ...string | Keys to remove. |
public echo(message: string): Promise<string, Error> source
import {echo} from 'webdismay/src/index.js'
echo message
Params:
Name | Type | Attribute | Description |
message | string |
public hash(k: string): Object source
import {hash} from 'webdismay/src/index.js'
Convenience function equivalent to new Hash(k)
Params:
Name | Type | Attribute | Description |
k | string | Key name |
public key(k: string): Object source
import {key} from 'webdismay/src/index.js'
Convenience function equivalent to new Key(k) to save typing "new" over and over
Params:
Name | Type | Attribute | Description |
k | string | Key name |
public keysMatching(pattern: String): Promise<string[], Error> source
import {keysMatching} from 'webdismay/src/index.js'
lists all keys or keys matching a pattern (via KEYS)
Params:
Name | Type | Attribute | Description |
pattern | String |
|
pattern to match |
public list(k: *): Object source
import {list} from 'webdismay/src/index.js'
convenience function equivalent to new List(k) to keep from typing "new" all the time
Params:
Name | Type | Attribute | Description |
k | * | Key |
public mget(redis: ...string): Promise<string[], Error> source
import {mget} from 'webdismay/src/index.js'
read multiple redis keys via MGET
Params:
Name | Type | Attribute | Description |
redis | ...string | keys to read |
public mset(obj: Object): Promise<Array, Error> source
import {mset} from 'webdismay/src/index.js'
set multiple redis keys from javascript object via MSET
Params:
Name | Type | Attribute | Description |
obj | Object | An object whose keys and (stringified) values are to be set on the redis server |
public msetnx(obj: Object): Promise<number, Error> source
import {msetnx} from 'webdismay/src/index.js'
set multiple redis keys if and only if none of the keys exist; sets all of the keys or none (via MSETNX)
Params:
Name | Type | Attribute | Description |
obj | Object | An object whose keys and (stringified) values are all to be set or none set. |
public randomKey(): Promise<string, Error> source
import {randomKey} from 'webdismay/src/index.js'
return an existing key at random (via RANDOMKEY)
public request(command: Array, endPoint: string): Promise<Object, MyError> source
import {request} from 'webdismay/src/index.js'
send a command array to webdis, return a Promise of a javascript object response. Put each redis command parameter in its own slot in the command array, ideally it will be automatically stringified and encoded as needed. The response object depends on which redis command was called.
public rset(k: *): Object source
import {rset} from 'webdismay/src/index.js'
Convenience function equivalent to new Rset(k), to avoid typing "new" over and over
Params:
Name | Type | Attribute | Description |
k | * | Key |
public select(index: *): Promise<Array, Error> source
import {select} from 'webdismay/src/index.js'
select which redis database to use for this connection (via SELECT). Untested!
Params:
Name | Type | Attribute | Description |
index | * | number of database |
public stringifyObjects(x: Object | Array | number | string): number | string source
import {stringifyObjects} from 'webdismay/src/index.js'
Pass non-objects unaltered, JSON.stringify objects/arrays. Shallow. Used by request preProcessing