Chapter 1. $fh.cache

$fh.cache(options, callback);

Cache an object in the cloud for a period of time.

1.1. Examples

Save a value to the cache

var options = {
  "act": "save",
  "key": "foo", // The key associated with the object
  "value": "bar", // The value to be cached, must be serializable
  "expire": 60 // Expiry time in seconds. Optional
};
$fh.cache(options, function (err, res) {
  if (err) return console.error(err.toString());

  // res is the original cached object
  console.log(res.toString());
});

Load a value from the cache

var options = {
  "act": "load",
  "key": "foo" // key to look for in cache
};
$fh.cache(options, function (err, res) {
  if (err) return console.error(err.toString());

  // res is the original cached object
  console.log(res.toString());
});

Remove a value from the cache

var options = {
  "act": "remove",
  "key": "foo" // key to look for in cache
};
$fh.cache(options, function (err, res) {
  if (err) return console.error(err.toString());

  // res is the removed cached object
  console.log(res.toString());
});