{"id":15602430,"url":"https://github.com/fiveisprime/iron-cache","last_synced_at":"2026-03-03T15:01:21.579Z","repository":{"id":12477046,"uuid":"15145202","full_name":"fiveisprime/iron-cache","owner":"fiveisprime","description":"Node.js implementation of Iron Cache.","archived":false,"fork":false,"pushed_at":"2016-09-13T01:13:42.000Z","size":21,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-07T17:04:21.054Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://npm.im/iron-cache","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fiveisprime.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-12T19:23:31.000Z","updated_at":"2018-01-27T11:28:26.000Z","dependencies_parsed_at":"2022-09-10T22:31:12.351Z","dependency_job_id":null,"html_url":"https://github.com/fiveisprime/iron-cache","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiveisprime%2Firon-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiveisprime%2Firon-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiveisprime%2Firon-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiveisprime%2Firon-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fiveisprime","download_url":"https://codeload.github.com/fiveisprime/iron-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250581333,"owners_count":21453640,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T02:41:30.401Z","updated_at":"2026-03-03T15:01:16.507Z","avatar_url":"https://github.com/fiveisprime.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Iron-Cache [![NPM version](https://badge.fury.io/js/iron-cache.svg)](http://badge.fury.io/js/iron-cache) [![Build Status](https://travis-ci.org/fiveisprime/iron-cache.svg?branch=master)](https://travis-ci.org/fiveisprime/iron-cache)\n==========\n\nNode.js implementation of Iron's [IronCache](http://www.iron.io/cache) product.\n\n# Usage\n\nCreate an [iron](http//www.iron.io) project. In your dashboard, click the\ncredentials link (the little key) to see your Project ID and Token. These are\nrequired to use the IronCache API with this module.\n\nInitialize the module using your Project ID and Token.\n\nYou can also add environment variables to your application to initialize the\nmodule. These variables are `IRON_CACHE_PROJECT` and `IRON_CACHE_TOKEN`. When\nusing the environment variables, there is no need to pass the options object\nwhen creating the client object.\n\n```js\nvar ironcache = require('iron-cache');\n\n// Pass an options object.\nvar client = ironcache.createClient({ project: 'project', token: 'token' });\n\n// When using the environment variables IRON_CACHE_PROJECT \u0026 IRON_CACHE_TOKEN.\n// This will throw an error if the environment variables are not set.\nvar client = ironcache.createClient();\n```\n\nThe API usage is split into two pieces: [cache management](#cache-management)\nand [key management](#key-management).\n\n## Cache Management\n\nThese methods are used to manage your caches. Create a new cache by\n[put](#put)ting a cache key/value pair to the cache.\n\n### List Caches\n\nEmpty or nonexistent caches will return an empty array.\n\n```js\nclient.list(function(err, res) {\n  if (err) throw err;\n  console.log(res);\n});\n```\n\nResponse:\n\n```js\n[\n  {\n    \"project_id\": \"PROJECT ID\",\n    \"name\": \"CACHE NAME\"\n  },\n  {\n    \"project_id\": \"PROJECT ID\",\n    \"name\": \"CACHE NAME\"\n  }\n]\n```\n\n### Cache Information\n\nGet information about a cache.\n\n```js\nclient.info('my-cache', function(err, res) {\n  if (err) throw err;\n  console.log(res);\n});\n```\n\nResponse:\n\n```js\n{\n  \"size\": \"cache size\"\n}\n```\n\n### Clear Cache\n\nClear all items in a cache.\n\n```js\nclient.clearCache('my-cache', function(err, res) {\n  if (err) throw err;\n  console.log(res);\n});\n```\n\nResponse:\n\n```js\n{\n  \"msg\": \"Cleared.\"\n}\n```\n\n### Delete Cache\n\nDelete a cache and all items in it.\n\n```js\nclient.delCache('my-cache', function(err, res) {\n  if (err) throw err;\n  console.log(res);\n});\n```\n\nResponse:\n\n```js\n{\n  \"msg\": \"Deleted.\"\n}\n```\n\n## Key Management\n\nCRUD the values stored in your caches.\n\n### Put\n\nPuts an item into a cache.\n\n```js\nclient.put('my-cache', 'key', { value: 'some data' }, function(err, res) {\n  if (err) throw err;\n  console.log(res);\n});\n```\n\nValue is required and is the data that will be persisted in the key. Other\navailable properties include the following.\n\n* `expires_in`: How long in seconds to keep the item in the cache before it is deleted. By default, items do not expire. Maximum is 2,592,000 seconds (30 days).\n* `replace`: If set to true, only set the item if the item is already in the cache. If the item is not in the cache, do not create it.\n* `add`: If set to true, only set the item if the item is not already in the cache. If the item is in the cache, do not overwrite it.\n* `cas`: If set, the new item will only be placed in the cache if there is an existing item with a matching key and cas value. An item’s cas value is automatically generated and is included when the item is retrieved.\n\nResponse:\n\n```js\n{\n  \"msg\": \"Stored.\"\n}\n```\n\n### Increment\n\nIncrement an item's value. The amount must be a number and attempting to\nincrement non-numeric values results in an error. Negative amounts may be passed\nto decrement the value. The increment is atomic, so concurrent increments will\nall be observed.\n\n```js\nclient.incr('my-cache', 'key', 1, function(err, res) {\n  if (err) throw err;\n  console.log(res);\n});\n```\n\nResponse:\n\n```js\n{\n  \"msg\": \"Added\",\n  \"value\": 132\n}\n```\n\n### Get\n\nRetrieve an item from the cache.\n\n```js\nclient.get('my-cache', 'key', function(err, res) {\n  if (err) throw err;\n  console.log(res);\n});\n```\n\nResponse:\n\n```js\n{\n  \"cache\": \"CACHE NAME\",\n  \"key\": \"ITEM KEY\",\n  \"value\": \"ITEM VALUE\",\n  \"cas\": \"12345\"\n}\n```\n\n### Delete\n\nDelete an item from the cache.\n\n```js\nclient.del('my-cache', 'key', function(err, res) {\n  if (err) throw err;\n  console.log(res);\n});\n```\n\nResponse:\n\n```js\n{\n  \"msg\": \"Deleted.\"\n}\n```\n\n# License\n\nThe MIT License (MIT)\n\nCopyright (c) 2014 Matt Hernandez\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiveisprime%2Firon-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffiveisprime%2Firon-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiveisprime%2Firon-cache/lists"}