{"id":16363135,"url":"https://github.com/e0ipso/cache-tags","last_synced_at":"2025-03-21T00:31:51.312Z","repository":{"id":31243211,"uuid":"126993827","full_name":"e0ipso/cache-tags","owner":"e0ipso","description":"Cache tags library for node.js","archived":false,"fork":false,"pushed_at":"2022-12-09T08:30:54.000Z","size":1107,"stargazers_count":9,"open_issues_count":7,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T02:02:12.744Z","etag":null,"topics":["cache","cacheability","cacheability-metadata","ioredis","performance","redis","tags"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/e0ipso.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":"2018-03-27T13:51:57.000Z","updated_at":"2022-03-24T05:17:14.000Z","dependencies_parsed_at":"2023-01-14T18:45:31.046Z","dependency_job_id":null,"html_url":"https://github.com/e0ipso/cache-tags","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e0ipso%2Fcache-tags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e0ipso%2Fcache-tags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e0ipso%2Fcache-tags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e0ipso%2Fcache-tags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/e0ipso","download_url":"https://codeload.github.com/e0ipso/cache-tags/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244536508,"owners_count":20468357,"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":["cache","cacheability","cacheability-metadata","ioredis","performance","redis","tags"],"created_at":"2024-10-11T02:26:36.622Z","updated_at":"2025-03-21T00:31:50.945Z","avatar_url":"https://github.com/e0ipso.png","language":"Ruby","readme":"\u003c!--\n  This file was generated by emdaer\n\n  Its template can be found at .emdaer/README.emdaer.md\n--\u003e\n\n\u003c!--\n  emdaerHash:261cd76b37249fc3c9f4bc01300c09c6\n--\u003e\n\n\u003ch1 id=\"cache-tags-img-src-logo-svg-alt-cache-tags-logo-title-cache-tags-logo-width-100-align-right-\"\u003eCache Tags \u003cimg src=\"./logo.svg\" alt=\"Cache Tags logo\" title=\"Cache Tags logo\" width=\"100\" align=\"right\"\u003e\u003c/h1\u003e\n\u003cp\u003e\u003c/p\u003e\u003cp align=\"center\"\u003e\nAdds cache tags for bulk invalidation.\n\u003c/p\u003e\u003cp\u003e\u003c/p\u003e\n\u003chr\u003e\n\n\u003c!-- toc --\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"#install\"\u003eInstall\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"#why\"\u003eWhy?\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"#contributors\"\u003eContributors\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003c!-- tocstop --\u003e\n\u003cp\u003e· \u003ca href=\"https://github.com/e0ipso/cache-tags/\"\u003e\u003cimg src=\"https://img.shields.io/github/workflows/status/e0ipso/cache-tags/test.yml/master?style=flat-square\" alt=\"GitHub Actions\"\u003e\u003c/a\u003e \u003ca href=\"https://github.com/emdaer/emdaer\"\u003e\u003cimg src=\"https://img.shields.io/badge/📓-documented%20with%20emdaer-F06632.svg?style=flat-square\" alt=\"Documented with emdaer\"\u003e\u003c/a\u003e\u003c/p\u003e\n\u003ch2 id=\"install\"\u003eInstall\u003c/h2\u003e\n\u003col\u003e\n\u003cli\u003e\u003ccode\u003eyarn add cache-tags\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://redis.io/download\"\u003eInstall Redis\u003c/a\u003e normally. If you want to spin up\na local cluster for testing you can use: \u003ccode\u003eyarn create-cluster\u003c/code\u003e and\n\u003ccode\u003eyarn destroy-cluster\u003c/code\u003e.\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch2 id=\"why-\"\u003eWhy?\u003c/h2\u003e\n\u003cp\u003eIf you need to invalidate cache entries that are related to each other, or just\nlist these cache entries that relate to each other you can use tags. You will\nneed to add the tags to the cache entries to be able to retrieve them later.\u003c/p\u003e\n\u003cp\u003eThis module only supports Redis as the cache back-end at the moment. It is\ntested against a single node and a cluster of 3 masters and 3 replicas.\u003c/p\u003e\n\u003cp\u003eConcept inspired by \u003ca href=\"https://www.drupal.org/\"\u003eDrupal\u003c/a\u003e 8’s\n\u003ca href=\"https://www.drupal.org/docs/8/api/cache-api/cache-tags\"\u003ecache tags\u003c/a\u003e. API and\nimplementation inspired by\n\u003ca href=\"https://laravel.com/docs/5.6/cache#cache-tags\"\u003eLaravel’s Cache Tags\u003c/a\u003e.\u003c/p\u003e\n\u003ch2 id=\"usage\"\u003eUsage\u003c/h2\u003e\n\u003cp\u003eIf you want to see more usage examples, check the\n\u003ca href=\"./__tests__/functional.js\"\u003efunctional tests\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eThis project uses \u003ca href=\"https://www.npmjs.com/package/ioredis\"\u003eioredis\u003c/a\u003e as the Redis\nclient. All the options for that project are available here.\u003c/p\u003e\n\n```js\nconst { TaggableCache: Redis } = require('cache-tags');\n\n// Initialize the Redis client as you would using ioredis.\nconst redis = new Redis('127.0.0.1:6379');\n// Now you can use `redis` as you would with ioredis, or you can enter tagged\n// mode.\nPromise.resolve()\n  // Use .tags to enter tagged mode, then call set or get.\n  .then(() =\u003e\n    Promise.all([\n      redis.tags(['first-tag']).set('cache-entry-1', 'Lorem', 1234),\n      redis.tags(['first-tag', 'boring']).set('cache-entry-2', 'Ipsum', 2324),\n    ])\n  )\n  .then(() =\u003e\n    Promise.all([\n      // You can scope gets by enterign tagged mode.\n      redis.tags(['first-tag']).get('cache-entry-1'),\n      // Or you can get the item as you would do normally.\n      redis.get('cache-entry-2'),\n    ])\n  )\n  .then(console.log) // ['Lorem', 'Ipsum'].\n  // You can also use tags to list items.\n  .then(() =\u003e redis.tags(['first-tag']).list())\n  .then(console.log) // ['Lorem', 'Ipsum'].\n  .then(() =\u003e redis.tags(['boring']).list())\n  .then(console.log) // ['Ipsum'].\n  // You can also use tags to invalidate items.\n  .then(() =\u003e redis.tags(['first-tag']).list())\n  .then(() =\u003e\n    Promise.all([\n      redis.tags(['first-tag']).get('cache-entry-1'),\n      redis.get('cache-entry-2'),\n    ])\n  )\n  .then(console.log); // []. Cache entries with tag 'first-tag' are gone.\n```\n\u003ch2 id=\"contributors\"\u003eContributors\u003c/h2\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributors\u003c/strong\u003e\u003c/summary\u003e\u003cbr\u003e\n\u003ca title=\"Engineer and programmer focused on online applications.\" href=\"https://github.com/e0ipso\"\u003e\n  \u003cimg align=\"left\" src=\"https://avatars0.githubusercontent.com/u/1140906?s=24\"\u003e\n\u003c/a\u003e\n\u003cstrong\u003eMateu Aguiló Bosch\u003c/strong\u003e\n\u003cbr\u003e\u003cbr\u003e\n\u003ca title=\"Software architect with an interest in distributed systems and elegant solutions.\" href=\"https://github.com/elliotttf\"\u003e\n  \u003cimg align=\"left\" src=\"https://avatars0.githubusercontent.com/u/447151?s=24\"\u003e\n\u003c/a\u003e\n\u003cstrong\u003eElliott Foster\u003c/strong\u003e\n\u003cbr\u003e\u003cbr\u003e\n\u003c/details\u003e\n\n\u003ch2 id=\"license\"\u003eLicense\u003c/h2\u003e\n\u003cp\u003ecache-tags is \u003ca href=\"./LICENSE\"\u003eMIT licensed\u003c/a\u003e.\u003c/p\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fe0ipso%2Fcache-tags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fe0ipso%2Fcache-tags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fe0ipso%2Fcache-tags/lists"}