Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed May 12, 2011
1 parent f41c021 commit 0a14af1
Show file tree
Hide file tree
Showing 10 changed files with 3,159 additions and 76 deletions.
36 changes: 19 additions & 17 deletions lib/Cache.js
Expand Up @@ -13,7 +13,7 @@
* Reference: * Reference:
* http://redis.io/commands#string * http://redis.io/commands#string
* *
* Redis structure: * Redis Structure:
* `(namespace:)cache_namespace:key = string` * `(namespace:)cache_namespace:key = string`
*/ */


Expand All @@ -38,15 +38,15 @@ Cache.prototype.getKey = function (key) {
* Cache one or more values. * Cache one or more values.
* *
* To cache a single value by key: * To cache a single value by key:
* cache.set('foo', 'bar', callback); * `cache.set('foo', 'bar', callback);`
* *
* To set multiple cached values by key: * To set multiple cached values by key:
* cache.set({foo:'bar', key2:'value2'}, callback); * `cache.set({foo:'bar', key2:'value2'}, callback);`
* *
* @param {string} key * @param {string} key
* @param {string} value * @param {string} value
* @param {Function} callback (optional) * @param {Function} callback (optional)
* @return this; * @return this
* @api public * @api public
*/ */


Expand Down Expand Up @@ -77,7 +77,7 @@ Cache.prototype.set = function (key, value, expiry, callback) {
* @param {string|Object} key * @param {string|Object} key
* @param {string} value (optional) * @param {string} value (optional)
* @param {Function} callback (optional) * @param {Function} callback (optional)
* @return this; * @return this
* @api public * @api public
*/ */


Expand All @@ -102,18 +102,18 @@ Cache.prototype.add = function (key, value, callback) {
* Get one or more values from the cache. * Get one or more values from the cache.
* *
* To get a single cached value by key: * To get a single cached value by key:
* cache.get('foo', callback); * `cache.get('foo', callback);`
* *
* To get multiple cached values by key: * To get multiple cached values by key:
* cache.get(['foo','bar'], callback); * `cache.get(['foo','bar'], callback);`
* *
* To get all cached values: * To get all cached values:
* cache.get(callback); * `cache.get(callback);`
* *
* @param {string} key * @param {string} key
* @param {string} value * @param {string} value
* @param {Function} callback * @param {Function} callback
* @return this; * @return this
* @api public * @api public
*/ */


Expand Down Expand Up @@ -161,7 +161,7 @@ Cache.prototype.get = function (key, callback) {
* @param {string} key * @param {string} key
* @param {string} value * @param {string} value
* @param {Function} callback * @param {Function} callback
* @return this; * @return this
* @api public * @api public
*/ */


Expand All @@ -175,7 +175,7 @@ Cache.prototype.getSet = function (key, value, callback) {
* *
* @param {string} key * @param {string} key
* @param {Function} callback * @param {Function} callback
* @return this; * @return this
* @api public * @api public
*/ */


Expand All @@ -190,11 +190,12 @@ Cache.prototype.exists = function (key, callback) {
* @param {string} key * @param {string} key
* @param {int} amount (optional - default is 1) * @param {int} amount (optional - default is 1)
* @param {Function} callback (optional) * @param {Function} callback (optional)
* @return this; * @return this
* @api public * @api public
*/ */


Cache.prototype.increment = Cache.prototype.incrBy = function (key, amount, callback) { Cache.prototype.increment =
Cache.prototype.incrBy = function (key, amount, callback) {
callback = callback || function () {}; callback = callback || function () {};
if (typeof amount === 'function') { if (typeof amount === 'function') {
callback = amount; callback = amount;
Expand All @@ -210,11 +211,12 @@ Cache.prototype.increment = Cache.prototype.incrBy = function (key, amount, call
* @param {string} key * @param {string} key
* @param {int} amount (optional - default is 1) * @param {int} amount (optional - default is 1)
* @param {Function} callback (optional) * @param {Function} callback (optional)
* @return this; * @return this
* @api public * @api public
*/ */


Cache.prototype.decrement = Cache.prototype.decrBy = function (key, amount, callback) { Cache.prototype.decrement =
Cache.prototype.decrBy = function (key, amount, callback) {
callback = callback || function () {}; callback = callback || function () {};
if (typeof amount === 'function') { if (typeof amount === 'function') {
callback = amount; callback = amount;
Expand All @@ -230,7 +232,7 @@ Cache.prototype.decrement = Cache.prototype.decrBy = function (key, amount, call
* @param {string} pattern (optional - default is *) * @param {string} pattern (optional - default is *)
* @param {bool} keep_namespace (optional - default is false) * @param {bool} keep_namespace (optional - default is false)
* @param {Function} callback * @param {Function} callback
* @return this; * @return this
* @api public * @api public
*/ */


Expand Down Expand Up @@ -269,7 +271,7 @@ Cache.prototype.keys = function (pattern, keep_namespace, callback) {
* *
* @param {string} pattern (optional - default is *) * @param {string} pattern (optional - default is *)
* @param {Function} callback (optional) * @param {Function} callback (optional)
* @return this; * @return this
* @api public * @api public
*/ */


Expand Down
6 changes: 3 additions & 3 deletions lib/Redback.js
Expand Up @@ -14,7 +14,7 @@ var redis = require('redis'),
Cache = require('./Cache').Cache; Cache = require('./Cache').Cache;


/** /**
* Define the Redis structures. * Define the available Redis structures.
*/ */


var base = ['Hash','List','Set','SortedSet','Bitfield']; var base = ['Hash','List','Set','SortedSet','Bitfield'];
Expand Down Expand Up @@ -129,7 +129,7 @@ exports.createClient = function (host, port, options) {
} }


/** /**
* Add the base structures from ./base_structures * Add the Redis structures from ./base_structures
*/ */


base.forEach(function (structure) { base.forEach(function (structure) {
Expand Down Expand Up @@ -160,4 +160,4 @@ Redback.prototype.NINF = exports.NINF = '-inf';
exports.Client = redis.RedisClient; exports.Client = redis.RedisClient;
exports.Structure = Structure.Structure; exports.Structure = Structure.Structure;
exports.Cache = Cache; exports.Cache = Cache;
exports.Channel exports.Channel = Channel;
4 changes: 2 additions & 2 deletions lib/advanced_structures/CappedList.js
Expand Up @@ -12,7 +12,7 @@ var List = require('../base_structures/List').List;


/** /**
* A Redis list with a fixed length. Each command that adds a value to the * A Redis list with a fixed length. Each command that adds a value to the
* list is followed by an LTRIM command. * list is followed by an `LTRIM` command.
* *
* Usage: * Usage:
* `redback.createCappedList(key [, max_length]);` * `redback.createCappedList(key [, max_length]);`
Expand All @@ -32,7 +32,7 @@ var CappedList = exports.CappedList = List.prototype.extend();
* *
* @param {int} length - the maximum length of the list * @param {int} length - the maximum length of the list
* @param {Function} callback * @param {Function} callback
* @api public * @api private
*/ */


CappedList.prototype.init = function (length) { CappedList.prototype.init = function (length) {
Expand Down
6 changes: 3 additions & 3 deletions lib/advanced_structures/SocialGraph.js
Expand Up @@ -14,14 +14,14 @@ var Structure = require('../Structure');
* Build a social graph similar to Twitter's. * Build a social graph similar to Twitter's.
* *
* Usage: * Usage:
* `redback.createSocialGraph(user_id [, prefix]);` * `redback.createSocialGraph(id [, prefix]);`
* *
* Reference: * Reference:
* http://redis.io/topics/data-types#sets * http://redis.io/topics/data-types#sets
* *
* Redis Structure: * Redis Structure:
* `(namespace:)(prefix:)user_id:following = set(user_ids)` * `(namespace:)(prefix:)id:following = set(ids)`
* `(namespace:)(prefix:)user_id:followers = set(user_ids)` * `(namespace:)(prefix:)id:followers = set(ids)`
*/ */


var SocialGraph = exports.SocialGraph = Structure.new(); var SocialGraph = exports.SocialGraph = Structure.new();
Expand Down
4 changes: 2 additions & 2 deletions lib/base_structures/Bitfield.js
Expand Up @@ -30,7 +30,7 @@ var Bitfield = exports.Bitfield = Structure.new();
* *
* @param {int} bit * @param {int} bit
* @param {Function} callback (optional) * @param {Function} callback (optional)
* @return this; * @return this
* @api public * @api public
*/ */


Expand All @@ -46,7 +46,7 @@ Bitfield.prototype.get = function (bit, callback) {
* @param {int} bit * @param {int} bit
* @param {bool} value * @param {bool} value
* @param {Function} callback (optional) * @param {Function} callback (optional)
* @return this; * @return this
* @api public * @api public
*/ */


Expand Down
32 changes: 16 additions & 16 deletions lib/base_structures/Hash.js
Expand Up @@ -29,7 +29,7 @@ var Hash = exports.Hash = Structure.new();
* Get an array of hash keys. * Get an array of hash keys.
* *
* @param {Function} callback * @param {Function} callback
* @return this; * @return this
* @api public * @api public
*/ */


Expand All @@ -42,7 +42,7 @@ Hash.prototype.keys = function (callback) {
* Get an array of hash values. * Get an array of hash values.
* *
* @param {Function} callback * @param {Function} callback
* @return this; * @return this
* @api public * @api public
*/ */


Expand All @@ -55,7 +55,7 @@ Hash.prototype.values = function (callback) {
* Get the number of hash keys. * Get the number of hash keys.
* *
* @param {Function} callback * @param {Function} callback
* @return this; * @return this
* @api public * @api public
*/ */


Expand All @@ -69,7 +69,7 @@ Hash.prototype.length = function (callback) {
* *
* @param {string} hash_key * @param {string} hash_key
* @param {Function} callback (optional) * @param {Function} callback (optional)
* @return this; * @return this
* @api public * @api public
*/ */


Expand All @@ -84,7 +84,7 @@ Hash.prototype.delete = Hash.prototype.del = function (hash_key, callback) {
* *
* @param {string} hash_key * @param {string} hash_key
* @param {Function} callback * @param {Function} callback
* @return this; * @return this
* @api public * @api public
*/ */


Expand All @@ -97,15 +97,15 @@ Hash.prototype.exists = function (hash_key, callback) {
* Sets one or more key/value pairs. * Sets one or more key/value pairs.
* *
* To set one key/value pair: * To set one key/value pair:
* hash.set('foo', 'bar', callback); * `hash.set('foo', 'bar', callback);`
* *
* To set multiple: * To set multiple:
* hash.set({key1:'value1', key2:'value2}, callback); * `hash.set({key1:'value1', key2:'value2}, callback);`
* *
* @param {string|Object} hash_key * @param {string|Object} hash_key
* @param {string} value (optional) * @param {string} value (optional)
* @param {Function} callback (optional) * @param {Function} callback (optional)
* @return this; * @return this
* @api public * @api public
*/ */


Expand All @@ -121,12 +121,12 @@ Hash.prototype.set = function (hash_key, value, callback) {
} }


/** /**
* Sets a key/value pair but only if the key doesn't already exist. * Sets a key/value pair if the key doesn't already exist.
* *
* @param {string} hash_key * @param {string} hash_key
* @param {string} value * @param {string} value
* @param {Function} callback * @param {Function} callback
* @return this; * @return this
* @api public * @api public
*/ */


Expand All @@ -140,15 +140,15 @@ Hash.prototype.add = function (hash_key, value, callback) {
* Gets one or more key/value pairs. * Gets one or more key/value pairs.
* *
* To get all key/value pairs in the hash: * To get all key/value pairs in the hash:
* hash.get('foo', callback); * `hash.get('foo', callback);`
* *
* To get certain key/value pairs: * To get certain key/value pairs:
* hash.get(['foo','bar'], callback); * `hash.get(['foo','bar'], callback);`
* hash.get('foo', callback); * `hash.get('foo', callback);`
* *
* @param {string} hash_key (optional) * @param {string} hash_key (optional)
* @param {Function} callback * @param {Function} callback
* @return this; * @return this
* @api public * @api public
*/ */


Expand All @@ -170,7 +170,7 @@ Hash.prototype.get = function (hash_key, callback) {
* @param {string} hash_key * @param {string} hash_key
* @param {int} amount (optional - default is 1) * @param {int} amount (optional - default is 1)
* @param {Function} callback (optional) * @param {Function} callback (optional)
* @return this; * @return this
* @api public * @api public
*/ */


Expand All @@ -191,7 +191,7 @@ Hash.prototype.incrBy = function (hash_key, amount, callback) {
* @param {string} hash_key * @param {string} hash_key
* @param {int} amount (optional - default is 1) * @param {int} amount (optional - default is 1)
* @param {Function} callback (optional) * @param {Function} callback (optional)
* @return this; * @return this
* @api public * @api public
*/ */


Expand Down
14 changes: 7 additions & 7 deletions lib/base_structures/List.js
Expand Up @@ -26,7 +26,7 @@ var Structure = require('../Structure');
var List = exports.List = Structure.new(); var List = exports.List = Structure.new();


/** /**
* Get an array of values in the list. * Get the list as an array.
* *
* @param {Function} callback * @param {Function} callback
* @return this * @return this
Expand Down Expand Up @@ -61,7 +61,7 @@ List.prototype.range = function (start, end, callback) {
* Get one or more elements starting at the specified index. * Get one or more elements starting at the specified index.
* *
* @param {int} index * @param {int} index
* @param {count} count (optional - defaults to 1) * @param {count} count (optional - default is 1)
* @param {Function} callback * @param {Function} callback
* @return this * @return this
* @api public * @api public
Expand All @@ -81,7 +81,7 @@ List.prototype.get = function (index, count, callback) {
* Cap the length of the list. * Cap the length of the list.
* *
* @param {int} length * @param {int} length
* @param {bool} keep_earliest (optional - defaults to false) * @param {bool} keep_earliest (optional - default is false)
* @param {Function} callback (optional) * @param {Function} callback (optional)
* @return this * @return this
* @api public * @api public
Expand All @@ -103,10 +103,10 @@ List.prototype.cap = function (length, keep_earliest, callback) {
} }


/** /**
* Remove one or more list elements matching the value * Remove one or more list elements matching the value.
* *
* @param {string} value * @param {string} value
* @param {bool} count (optional - defaults to 1) * @param {bool} count (optional - default is 1)
* @param {Function} callback (optional) * @param {Function} callback (optional)
* @return this * @return this
* @api public * @api public
Expand All @@ -123,11 +123,11 @@ List.prototype.remove = function (value, count, callback) {
} }


/** /**
* Trim a list to the specified range. * Trim a list to the specified bounds.
* *
* @param {int} start * @param {int} start
* @param {int} end * @param {int} end
* @param {Function} callback (optional_ * @param {Function} callback (optional)
* @return this * @return this
* @api public * @api public
*/ */
Expand Down

0 comments on commit 0a14af1

Please sign in to comment.