Merge pull request #1093 from strongloop/docs-for-kvao
Add docs for KVAO
This commit is contained in:
commit
7365e3200b
|
@ -4,15 +4,17 @@ var assert = require('assert');
|
|||
var utils = require('../utils');
|
||||
|
||||
/**
|
||||
* Set expiration (TTL) for the given key.
|
||||
* Set the TTL (time to live) in ms (milliseconds) for a given key. TTL is the
|
||||
* remaining time before a key-value pair is discarded from the database.
|
||||
*
|
||||
* @param {String} key
|
||||
* @param {Number} ttl
|
||||
* @param {Object} options
|
||||
* @callback cb
|
||||
* @param {Error} error
|
||||
* @param {String} key Key to use when searching the database.
|
||||
* @param {Number} ttl TTL in ms to set for the key.
|
||||
* @options {Object} options
|
||||
* @callback {Function} callback
|
||||
* @param {Error} err Error object.
|
||||
* @promise
|
||||
*
|
||||
* @header KVAO.get(key, cb)
|
||||
* @header KVAO.expire(key, ttl, cb)
|
||||
*/
|
||||
module.exports = function keyValueExpire(key, ttl, options, callback) {
|
||||
if (callback == undefined && typeof options === 'function') {
|
||||
|
@ -30,4 +32,3 @@ module.exports = function keyValueExpire(key, ttl, options, callback) {
|
|||
this.getConnector().expire(this.modelName, key, ttl, options, callback);
|
||||
return callback.promise;
|
||||
};
|
||||
|
||||
|
|
|
@ -4,12 +4,14 @@ var assert = require('assert');
|
|||
var utils = require('../utils');
|
||||
|
||||
/**
|
||||
* Get the value stored for the given key.
|
||||
* Return the value associated with a given key.
|
||||
*
|
||||
* @param {String} key
|
||||
* @callback cb
|
||||
* @param {Error} error
|
||||
* @param {*} value
|
||||
* @param {String} key Key to use when searching the database.
|
||||
* @options {Object} options
|
||||
* @callback {Function} callback
|
||||
* @param {Error} err Error object.
|
||||
* @param {*} result Value associated with the given key.
|
||||
* @promise
|
||||
*
|
||||
* @header KVAO.get(key, cb)
|
||||
*/
|
||||
|
|
|
@ -4,18 +4,17 @@ var assert = require('assert');
|
|||
var utils = require('../utils');
|
||||
|
||||
/**
|
||||
* Asynchronously iterate all keys.
|
||||
* Asynchronously iterate all keys in the database. Similar to `.keys()` but
|
||||
* instead allows for iteration over large data sets without having to load
|
||||
* everything into memory at once.
|
||||
*
|
||||
* @param {Object} filter An optional filter object with the following
|
||||
* properties:
|
||||
* - `match` - glob string to use to filter returned keys, e.g. 'userid.*'
|
||||
* All connectors are required to support `*` and `?`.
|
||||
* They may also support additional special characters that are specific
|
||||
* to the backing store.
|
||||
*
|
||||
* @param {String} filter.match Glob string to use to filter returned
|
||||
* keys (i.e. `userid.*`). All connectors are required to support `*` and
|
||||
* `?`. They may also support additional special characters that are
|
||||
* specific to the backing database.
|
||||
* @param {Object} options
|
||||
*
|
||||
* @returns {AsyncIterator} An object implementing "next(cb) -> Promise"
|
||||
* @returns {AsyncIterator} An Object implementing `next(cb) -> Promise`
|
||||
* function that can be used to iterate all keys.
|
||||
*
|
||||
* @header KVAO.iterateKeys(filter)
|
||||
|
|
|
@ -4,25 +4,22 @@ var assert = require('assert');
|
|||
var utils = require('../utils');
|
||||
|
||||
/**
|
||||
* Get all keys.
|
||||
* Return all keys in the database.
|
||||
*
|
||||
* **NOTE**
|
||||
* Building an in-memory array of all keys may be expensive.
|
||||
* Consider using `iterateKeys` instead.
|
||||
* **WARNING**: This method is not suitable for large data sets as all
|
||||
* key-values pairs are loaded into memory at once. For large data sets,
|
||||
* use `iterateKeys()` instead.
|
||||
*
|
||||
* @param {Object} filter An optional filter object with the following
|
||||
* properties:
|
||||
* - `match` - glob string to use to filter returned keys, e.g. 'userid.*'
|
||||
* All connectors are required to support `*` and `?`.
|
||||
* They may also support additional special characters that are specific
|
||||
* to the backing store.
|
||||
* @param {String} filter.match Glob string used to filter returned
|
||||
* keys (i.e. `userid.*`). All connectors are required to support `*` and
|
||||
* `?`, but may also support additional special characters specific to the
|
||||
* database.
|
||||
* @param {Object} options
|
||||
* @callback callback
|
||||
* @param {Error=} err
|
||||
* @param {[String]} keys The list of keys.
|
||||
*
|
||||
* @callback {Function} callback
|
||||
* @promise
|
||||
*
|
||||
*
|
||||
* @header KVAO.keys(filter, callback)
|
||||
*/
|
||||
module.exports = function keyValueKeys(filter, options, callback) {
|
||||
|
@ -57,4 +54,3 @@ module.exports = function keyValueKeys(filter, options, callback) {
|
|||
|
||||
return callback.promise;
|
||||
};
|
||||
|
||||
|
|
|
@ -4,12 +4,17 @@ var assert = require('assert');
|
|||
var utils = require('../utils');
|
||||
|
||||
/**
|
||||
* Set the value for the given key.
|
||||
* Persist a value and associate it with the given key.
|
||||
*
|
||||
* @param {String} key
|
||||
* @param {*} value
|
||||
* @callback cb
|
||||
* @param {Error} error
|
||||
* @param {String} key Key to associate with the given value.
|
||||
* @param {*} value Value to persist.
|
||||
* @options {Number|Object} options Optional settings for the key-value
|
||||
* pair. If a Number is provided, it is set as the TTL (time to live) in ms
|
||||
* (milliseconds) for the key-value pair.
|
||||
* @property {Number} ttl TTL for the key-value pair in ms.
|
||||
* @callback {Function} callback
|
||||
* @param {Error} err Error object.
|
||||
* @promise
|
||||
*
|
||||
* @header KVAO.set(key, value, cb)
|
||||
*/
|
||||
|
@ -37,4 +42,3 @@ module.exports = function keyValueSet(key, value, options, callback) {
|
|||
this.getConnector().set(this.modelName, key, value, options, callback);
|
||||
return callback.promise;
|
||||
};
|
||||
|
||||
|
|
|
@ -4,14 +4,16 @@ var assert = require('assert');
|
|||
var utils = require('../utils');
|
||||
|
||||
/**
|
||||
* Get remaining expiration (TTL) for a given key.
|
||||
* Return the TTL (time to live) for a given key. TTL is the remaining time
|
||||
* before a key-value pair is discarded from the database.
|
||||
*
|
||||
* @param {String} key
|
||||
* @param {Object} options
|
||||
* @callback cb
|
||||
* @param {String} key Key to use when searching the database.
|
||||
* @options {Object} options
|
||||
* @callback {Function} callback
|
||||
* @param {Error} error
|
||||
* @param {Number} ttl The remaining TTL for the given key. `undefined` if TTL
|
||||
* was not initially set.
|
||||
* @param {Number} ttl Expiration time for the key-value pair. `undefined` if
|
||||
* TTL was not initially set.
|
||||
* @promise
|
||||
*
|
||||
* @header KVAO.ttl(key, cb)
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue