{"id":44205,"library":"adonis5-cache","title":"Adonis5 Cache","description":"A cache provider for AdonisJS 5 supporting multiple storage backends: in-memory, Redis, and Memcached. Version 1.3.1 (latest) is stable with moderate release cadence. It offers a unified CacheManager API with custom storage support, cache tags, TTL control, events, and fallback. Differentiators include first-class AdonisJS integration via IoC container, synchronous in-memory store, and extensibility for custom storage drivers. Requires peer dependencies for Redis and Memcached backends. Ships TypeScript types.","status":"active","version":"1.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/reg2005/adonis5-cache","tags":["javascript","Adonis","5","adonis-cache","typescript"],"install":[{"cmd":"npm install adonis5-cache","lang":"bash","label":"npm"},{"cmd":"yarn add adonis5-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add adonis5-cache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides cache event dispatching (e.g., cache:miss, cache:hit)","package":"@adonisjs/events","optional":false},{"reason":"Required for Redis cache storage backend","package":"@adonisjs/redis","optional":true},{"reason":"Required for Memcached cache storage backend","package":"adonis5-memcached-client","optional":true}],"imports":[{"note":"AdonisJS uses IoC container paths; direct import from npm package will fail.","wrong":"import Cache from 'adonis5-cache'","symbol":"Cache","correct":"import Cache from '@ioc:Adonis/Addons/Adonis5-Cache'"},{"note":"CacheManager is exported as default via Cache; named export not available.","wrong":"import { CacheManager } from 'adonis5-cache'","symbol":"CacheManager","correct":"import Cache from '@ioc:Adonis/Addons/Adonis5-Cache'"},{"note":"Type-only import for implementing custom storages.","wrong":"import { CacheStorageContract } from 'adonis5-cache'","symbol":"CacheStorageContract","correct":"import { CacheStorageContract } from '@ioc:Adonis/Addons/Adonis5-Cache'"},{"note":"Named type import for context in custom storage methods.","wrong":"import CacheContextContract from 'adonis5-cache'","symbol":"CacheContextContract","correct":"import { CacheContextContract } from '@ioc:Adonis/Addons/Adonis5-Cache'"}],"quickstart":{"code":"// 1. Install and invoke provider\n// npm i --save adonis5-cache\n// node ace invoke adonis5-cache\n\n// 2. Configure config/cache.ts\n{\n  currentCacheStorage: 'memory',\n  enabledCacheStorages: ['memory']\n}\n\n// 3. Use in service\nimport Cache from '@ioc:Adonis/Addons/Adonis5-Cache'\n\nexport default class UserService {\n  public async getUser(id: number) {\n    const cached = await Cache.get<{ name: string }>(`user:${id}`)\n    if (cached) {\n      return cached\n    }\n    const user = { name: 'John' } // fetch from DB\n    await Cache.put(`user:${id}`, 60, user)\n    return user\n  }\n}\n\n// 4. Register custom storage (optional)\nimport { CacheStorageContract } from '@ioc:Adonis/Addons/Adonis5-Cache'\nclass MyStorage implements CacheStorageContract {\n  get<T>(context: any, key: string): Promise<T | null> { return null }\n  getMany<T>(context: any, keys: string[]): Promise<(T | null)[]> { return [] }\n  put(context: any, key: string, value: any, ttl: number): void {}\n  putMany(context: any, dict: Record<string, any>, ttl: number): void {}\n}\nCache.registerStorage('my', new MyStorage())","lang":"typescript","description":"Installation, basic in-memory caching with get/put, and custom storage registration."},"warnings":[{"fix":"Always use Cache.put(key, ttl, value) or check documentation for correct order.","message":"Cache.put signature: key, ttl, value (not key, value, ttl). Mismatch causes unexpected behavior.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use the exact IoC path in all imports.","message":"IoC path '@ioc:Adonis/Addons/Adonis5-Cache' is required; direct require or import from package name fails silently.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update import to '@ioc:Adonis/Addons/Adonis5-Cache' and use Cache instead of CacheManager.","message":"Breaking change in v1.3.0: CacheManager renamed to Cache, and import path changed from '@ioc:Adonis/Addons/AdonisCache'.","severity":"breaking","affected_versions":"<1.3.0"},{"fix":"Move custom storage registration to config/cache.ts under the 'storages' key.","message":"Cache.registerStorage is deprecated in favor of config-driven storage registration in config/cache.ts.","severity":"deprecated","affected_versions":">=1.3.0"}],"env_vars":null,"search_vec":"'1.3.1':20 '5':8,79 'adoni':78,81 'adonis-cach':80 'adonis5':1 'adonisj':7,50 'api':33 'backend':12,73 'cach':2,4,38,82 'cachemanag':32 'cadenc':27 'class':49 'contain':54 'control':41 'custom':35,63 'depend':68 'differenti':45 'driver':65 'event':42 'extens':61 'fallback':44 'first':48 'first-class':47 'in-memori':13,56 'includ':46 'integr':51 'ioc':53 'javascript':77 'latest':21 'memcach':18,72 'memori':15,58 'moder':25 'multipl':10 'offer':29 'peer':67 'provid':5 'redi':16,70 'releas':26 'requir':66 'ship':74 'stabl':23 'storag':11,36,64 'store':59 'support':9,37 'synchron':55 'tag':39 'ttl':40 'type':76 'typescript':75,83 'unifi':31 'version':19 'via':52","created_at":"2026-06-07T12:48:58.896282+00:00","updated_at":"2026-06-07T12:48:58.896282+00:00","problems":[{"fix":"Run 'node ace invoke adonis5-cache' to regenerate the IoC mappings.","cause":"Provider not invoked or not registered in .adonisrc.json.","error":"Cannot find module '@ioc:Adonis/Addons/Adonis5-Cache'"},{"fix":"Use 'import Cache from ...' (default) not 'import { Cache } from ...'.","cause":"Using Named export instead of default import.","error":"TypeError: Cache.get is not a function"},{"fix":"Run commands with appropriate permissions or as non-root user.","cause":"Filesystem permission issue during invoke or compilation.","error":"Error: EACCES: permission denied, open '/path/to/node_modules/adonis5-cache/...'"}],"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/reg2005/adonis5-cache#readme","github":"https://github.com/reg2005/adonis5-cache","docs":null,"changelog":null,"pypi":null,"npm":"adonis5-cache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"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}}