{"id":44503,"library":"cache-tags","title":"cache-tags","description":"Cache Tags is an npm library (v2.9.1) that adds cache tagging for bulk invalidation, supporting Redis (single node and cluster) as the backend. It wraps the ioredis client to allow associating cache entries with tags, enabling listing entries by tag and invalidating all entries for a tag atomically. Inspired by Drupal 8 and Laravel cache tags, it has a low release cadence and is tested against Redis clusters. Key differentiators include simple tag-based get/set/invalidation and listing operations.","status":"active","version":"2.9.1","language":"javascript","source_language":"en","source_url":"https://github.com/e0ipso/cache-tags","tags":["javascript"],"install":[{"cmd":"npm install cache-tags","lang":"bash","label":"npm"},{"cmd":"yarn add cache-tags","lang":"bash","label":"yarn"},{"cmd":"pnpm add cache-tags","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"The library wraps ioredis to provide tagged caching on top of Redis","package":"ioredis","optional":false}],"imports":[{"note":"Package is ESM-only? Actually README shows require, so CJS is supported. Both patterns work.","wrong":"const TaggableCache = require('cache-tags')","symbol":"TaggableCache","correct":"import { TaggableCache } from 'cache-tags'"},{"note":"Default export may not exist; prefer named import TaggableCache.","wrong":"const CacheTags = require('cache-tags').default","symbol":"default","correct":"import CacheTags from 'cache-tags'"},{"note":"CJS destructuring works; direct property access also works but less idiomatic.","wrong":"const TaggableCache = require('cache-tags').TaggableCache","symbol":"TaggableCache","correct":"const { TaggableCache } = require('cache-tags')"}],"quickstart":{"code":"const { TaggableCache: Redis } = require('cache-tags');\n\nconst redis = new Redis('127.0.0.1:6379');\n\nPromise.resolve()\n  .then(() =>\n    Promise.all([\n      redis.tags(['first-tag']).set('entry1', 'Lorem', 1234),\n      redis.tags(['first-tag', 'boring']).set('entry2', 'Ipsum', 2324),\n    ])\n  )\n  .then(() =>\n    Promise.all([\n      redis.tags(['first-tag']).get('entry1'),\n      redis.get('entry2'),\n    ])\n  )\n  .then(console.log)\n  .then(() => redis.tags(['first-tag']).list())\n  .then(console.log)\n  .then(() => redis.tags(['boring']).list())\n  .then(console.log)\n  .then(() => redis.tags(['first-tag']).invalidate())\n  .then(() =>\n    Promise.all([\n      redis.tags(['first-tag']).get('entry1'),\n      redis.get('entry2'),\n    ])\n  )\n  .then(console.log);","lang":"javascript","description":"Demonstrates set/get with tags, listing entries by tag, and invalidation of all entries for a tag."},"warnings":[{"fix":"Install and run Redis before using the library.","message":"Requires Redis server – no in-memory fallback.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Pass connection options (string or object) as constructor argument.","message":"The constructor TaggableCache constructor expects ioredis config – not a direct ioredis instance.","severity":"deprecated","affected_versions":">=1.0.0 <3.0.0"},{"fix":"Re-enter tagged mode via redis.tags() after each invalidate() call.","message":"Tagged mode returns a different object – do not reuse the tagged cache client after calling invalidate().","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Be aware that invalidation is tag-based, not TTL-based.","message":"Keys with same tag but different TTL: invalidation removes them all regardless of expiration.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'8':55 'add':12 'allow':33 'associ':34 'atom':51 'backend':26 'base':78 'bulk':16 'cach':2,4,13,35,58 'cache-tag':1 'cadenc':65 'client':31 'cluster':23,71 'differenti':73 'drupal':54 'enabl':39 'entri':36,41,47 'get/set/invalidation':79 'includ':74 'inspir':52 'invalid':17,45 'ioredi':30 'javascript':83 'key':72 'laravel':57 'librari':9 'list':40,81 'low':63 'node':21 'npm':8 'oper':82 'redi':19,70 'releas':64 'simpl':75 'singl':20 'support':18 'tag':3,5,14,38,43,50,59,77 'tag-bas':76 'test':68 'v2.9.1':10 'wrap':28","created_at":"2026-06-07T12:50:26.891827+00:00","updated_at":"2026-06-07T12:50:26.891827+00:00","problems":[{"fix":"Start Redis: `redis-server` (or verify host/port).","cause":"Redis server is not running or not reachable.","error":"Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED"},{"fix":"Ensure you used `const { TaggableCache: Redis } = require('cache-tags');` and not `const Redis = require('ioredis');`.","cause":"Attempting to call .tags() on a regular ioredis instance, not a TaggableCache instance.","error":"TypeError: redis.tags is not a function"},{"fix":"Use `.tags(['my-tag']).set(key, value, ttl)` – note the array of tags, not a string.","cause":"Calling .set() on the result of .tags() before entering tagged mode correctly.","error":"TypeError: redis.tags(...).set is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/e0ipso/cache-tags#readme","github":"https://github.com/e0ipso/cache-tags","docs":null,"changelog":null,"pypi":null,"npm":"cache-tags","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}