{
"name": "fscache",
"main": "lib/cache.js",
"version": "0.0.1",
"author": {
"name": "Trevor Landau",
"email": "landautrevor@gmail.com"
},
"description": "A caching utility that stores data as json in files",
"scripts": {
"test": "grunt"
},
"repository": {
"type": "git",
"url": "https://github.com/landau/fscache"
},
"bugs": {
"url": "https://github.com/landau/fscache/issues"
},
"keywords": [
"cache",
"file",
"filesystem",
"utility",
"util"
],
"licenses": [
{
"type": "MIT",
"url": "https://github.com/landau/fscache/LICENSE-MIT"
}
],
"dependencies": {
"async": "~0.2.6"
},
"devDependencies": {
"grunt": "~0.4.0",
"grunt-contrib-jshint": "~0.2.0",
"grunt-mocha-test": "~0.2.0",
"should": "~1.2.2"
},
"engines": {
"node": ">=0.8.0"
},
"readme": "`version 0.0.1`\n\n# FSCache\n`FSCache` is a filesystem based caching utility. It stores values based on `key/value`. `Key` and `Value` must both be JSON serializable.\n\n## Where should I use this\nSince `FSCache` writes to disk (obviously), you should not use this tool as a frequently accessed data store for high traffic websites/web apis. `FSCache` is better used for **command line tools**, infrequently accessed configurations, or any project where you need a lightweight `key/val` store and performance for high traffic is not a concern.\n\nThough the api contains both `sync` and `async` versions for accessing the cache, reading/writing to disk is an expensive process.\n\n## Install\n\n`npm install fscache`\n\n\n## API\nAs typical in node, there is a `async` and `sync` version of each method.\n\n### Creating a new cache\nThis method creates a new directory that you specify which will act as your cache storage.\nIt returns a `Cache` object for accessing the cache.\n\n```\n/*\n * @param {Number} ttl - how long to store a value. null will store forever\n *\t\tdefault: null\n * @param {String} dir - Where to store data\n */\n\nvar Cache = require(\"fscache\");\n\n// Async\nCache.create(50, dir, function (err, cache) {\n\t// Do stuff with cache\t\n});\n\n// Sync\nvar cache = Cache.createSync(1000, dir);\n```\n\n### Put\nStore data\n\n```\n/*\n * @visibility private\n * @param {Mixed} key - A JSON stringifiable value \n * @param {Mixed} val - a JSON stringifiable value\n */\n \n // Async\n cache.put({id: 1}, \"cached\", function(err), function () {\n });\n \n cache.putSync({id: 2}, {cached: \"data\"});\n```\n\n### Get\nGet a stored value\n\n```\n/*\n * @param {Mixed} key - A JSON stringifiable key that is used to lookup\n * up a cached file\n */\n \n // Async\n cache.get({id: 1}, function (err, val) {\n if (err) throw err;\n console.log(val); // \"cached\";\n });\n \n // Sync\n var val = cache.get({id: 2});\n console.log(val); // {cached: \"data\"}\n \n```\n\n### Del\n\n```\n/*\n * @param {Mixed} key - A JSON stringifiable key that is used to lookup\n * up a cached file\n */\n \n // Async\n cache.del({id:1}, function (err) {\n if (err) throw err;\n });\n \n // Sync\n cache.del({id: 2});\n```",
"readmeFilename": "README.md",
"homepage": "https://github.com/landau/fscache",
"_id": "fscache@0.0.1",
"_shasum": "b375c94f7c36a9380c54371824c7952529eed928",
"_resolved": "git+https://github.com/nuxlli/fscache#91a9a163a82d94cfa769ebb614dd894069ccf304",
"_from": "fscache@git+https://github.com/nuxlli/fscache"
}