new MTable(opts)
In-memory key/value storage with the same data structure API as the DTable class. Does not include functionality to persist to disk.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
Object |
Properties
|
- Source:
Methods
(static) invalidTypeError(command, key, type) → {Error}
Parameters:
Name | Type | Description |
---|---|---|
command |
String | |
key |
String | |
type |
String |
- Source:
Returns:
- Type
- Error
clear() → {Clusterluck.MTable}
Clears the contents of this table.
- Source:
Returns:
This instance.
- Type
- Clusterluck.MTable
del(key) → {Clusterluck.MTable}
Removes key key
from this table.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | Key to remove from this table. |
- Source:
Returns:
This instance.
- Type
- Clusterluck.MTable
forEach(cb, fin)
Asynchronously iterates over each key/value pair stored in this table at the point of this call.
Parameters:
Name | Type | Description |
---|---|---|
cb |
function | Function to call on each key/value pair. Has the signature |
fin |
function | Finishing callback to call once iteration has completed. Hash the signature |
- Source:
forEachSync(cb) → {Clusterluck.MTable}
Synchronously iterates over each key/value pair stored in this table.
Parameters:
Name | Type | Description |
---|---|---|
cb |
function | Function call on each key/value pair. Has the signature |
- Source:
Returns:
This instance.
- Type
- Clusterluck.MTable
get(key) → {Map|Set|JSON}
Retrieves value stored at key
, returning undefined
if no such data exists.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | Key to retrieve data from. |
- Source:
Returns:
Value stored at key
.
- Type
- Map | Set | JSON
hdel(key, hkey) → {Clusterluck.MTable}
Removes the hash key hkey
from the hash map stored under key
.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | Key which holds the hash map that |
hkey |
String | The hash key to remove from the hash map. |
- Source:
Returns:
This instance.
- Type
- Clusterluck.MTable
hget(key, hkey) → {JSON}
Retrieves value stored at hash key hkey
under storage key key
, returning undefined
if no such data exists.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | Key to retrieve hash map from. |
hkey |
String | Hash key to retrieve data from. |
- Source:
Returns:
- Value stored under hash key
hkey
at the hash map stored underkey
.
- Type
- JSON
hset(key, hkey, val) → {Map}
Sets value
under the hash key hkey
in the hash map stored at key
.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | Key which holds the hash map. |
hkey |
String | Hash key to insert |
val |
JSON | Value to set under |
- Source:
Returns:
The map stored at key
.
- Type
- Map
idle() → {Boolean}
Returns whether this table is in an idle state or not.
- Source:
Returns:
Whether this table is idle or not.
- Type
- Boolean
load(cb)
Trivial call to load state.
Parameters:
Name | Type | Description |
---|---|---|
cb |
function | Function of the form |
- Source:
sdel(key, val) → {Clusterluck.MTable}
Deletes val
from the set stored under key
.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | Key which olds the set to remove |
val |
String | Value to remove from the set. |
- Source:
Returns:
This instance.
- Type
- Clusterluck.MTable
set(key, val) → {Map|Set|JSON}
Sets value value
under key key
.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | |
val |
Map | Set | JSON |
- Source:
Returns:
- Type
- Map | Set | JSON
smember(key, val) → {Boolean}
Returns whether val
is a member of the set stored at key
.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | Key to retrieve set from. |
val |
String | Value to check existence of in the set. |
- Source:
Returns:
Whether val
is a member of the set stored at key
.
- Type
- Boolean
sset(key, val) → {String}
Inserts val
into the set stored at key key
.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | Key which holds the set to insert |
val |
String | Value to insert into the set. |
- Source:
Returns:
The set stored at key
.
- Type
- String
start(name) → {Clusterluck.MTable}
Starts dtable instance, which triggers an fopen call to LATEST.LOG, the fsync interval for this log file, as well as other internal intervals to check for storage snapshot flush conditions.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Name of table, meant for debugging purposes. |
- Source:
Returns:
This instance.
- Type
- Clusterluck.MTable
stop(cb)
Stops the table, including all internal disk-based logic. If the table is idle and has an open file descriptor against LATEST.LOG, it will close immediately. If it's idle but the file descriptor against LATEST.LOG has been closed, this call will wait for a file descriptor to open again before continuing. Otherwise, the table isn't idle and therefore we wait for this condition.
Parameters:
Name | Type | Description |
---|---|---|
cb |
function | Callback called once the table has been stopped. |
- Source: