{"_id":"@api-craft/cache","_rev":"2-3474684786422a4ce00dac8fdb123167","name":"@api-craft/cache","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@api-craft/cache","version":"1.0.0","keywords":["express","cache","middleware","redis","memcached","in-memory","api-craft","ecosystem"],"author":{"name":"P. Thamilselven"},"license":"MIT","_id":"@api-craft/cache@1.0.0","maintainers":[{"name":"tselven_me","email":"tselven13@gmail.com"}],"homepage":"https://github.com/api-craft/cache.git#readme","bugs":{"url":"https://github.com/api-craft/cache.git/issues"},"dist":{"shasum":"08bae083e7dab434aa39d4483b1d58867748a6c2","tarball":"https://registry.npmjs.org/@api-craft/cache/-/cache-1.0.0.tgz","fileCount":5,"integrity":"sha512-yjnHyuaaHQcfN/xfQSONdBt3MA8YLpnHEROjmCBhqsVIXMdsP4Zy/xgbqMDgziG3BDpjaBRJADHk3//35WYsEA==","signatures":[{"sig":"MEUCIQDusVR2tzBXdTAQKextwm1FTRCCwwJwas72WWIZI182CQIgR0vUDPtWt7wv/k7rwYxeUYrxjOO3H9TeXZNso1WHi0s=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6934},"main":"index.js","type":"module","_from":"file:api-craft-cache-1.0.0.tgz","scripts":{"test":"echo \"No tests specified yet\" && exit 0"},"_npmUser":{"name":"tselven_me","actor":{"name":"tselven_me","type":"user","email":"tselven13@gmail.com"},"email":"tselven13@gmail.com"},"_resolved":"C:\\Users\\DELL\\AppData\\Local\\Temp\\2d476ffdeb9156f11537d13305b6464e\\api-craft-cache-1.0.0.tgz","_integrity":"sha512-yjnHyuaaHQcfN/xfQSONdBt3MA8YLpnHEROjmCBhqsVIXMdsP4Zy/xgbqMDgziG3BDpjaBRJADHk3//35WYsEA==","repository":{"url":"git+https://github.com/api-craft/cache.git","type":"git"},"_npmVersion":"10.9.2","description":"Unified caching middleware for Express.js supporting memory, Redis, and Memcached stores. Part of the API Craft ecosystem.","directories":{},"_nodeVersion":"22.14.0","dependencies":{"redis":"^4.6.7","memcached":"^2.2.2"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/cache_1.0.0_1750490084995_0.796772294395568","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@api-craft/cache","version":"1.0.1","description":"Unified caching middleware for Express.js supporting memory, Redis, and Memcached stores. Part of the API Craft ecosystem.","main":"index.js","type":"module","keywords":["express","cache","middleware","redis","memcached","in-memory","api-craft","ecosystem"],"author":{"name":"P. Thamilselven"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/api-craft/cache.git"},"homepage":"https://github.com/api-craft/cache.git#readme","bugs":{"url":"https://github.com/api-craft/cache.git/issues"},"dependencies":{"redis":"^4.6.7","memcached":"^2.2.2"},"scripts":{"test":"echo \"No tests specified yet\" && exit 0"},"_id":"@api-craft/cache@1.0.1","_integrity":"sha512-qYu2T8lsRyaAToIp1fcPtGAToRC0CzyxDNSoY0N2NH7ft8eE5pOc0XUS1P3/g/szzpu6diDoce3+S/UNf5QCug==","_resolved":"C:\\Users\\DELL\\AppData\\Local\\Temp\\c16a10c24d4bd49d6426465e91293ba7\\api-craft-cache-1.0.1.tgz","_from":"file:api-craft-cache-1.0.1.tgz","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-qYu2T8lsRyaAToIp1fcPtGAToRC0CzyxDNSoY0N2NH7ft8eE5pOc0XUS1P3/g/szzpu6diDoce3+S/UNf5QCug==","shasum":"d7f1f4a12afb71602d8fed1dfc40fdaef31141d6","tarball":"https://registry.npmjs.org/@api-craft/cache/-/cache-1.0.1.tgz","fileCount":6,"unpackedSize":10825,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDy7O5geDDlLBU2r6OHxzqtJ2oWozuaps7GSC+i3NfdZwIhAJy0m9BgIPf4gmqXYRFnHwfMCMrJED1/PeUdPM/SoVOv"}]},"_npmUser":{"name":"tselven_me","email":"tselven13@gmail.com","actor":{"name":"tselven_me","email":"tselven13@gmail.com","type":"user"}},"directories":{},"maintainers":[{"name":"tselven_me","email":"tselven13@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cache_1.0.1_1750491130038_0.4371724516518163"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-21T07:14:44.915Z","modified":"2025-06-21T07:32:10.398Z","1.0.0":"2025-06-21T07:14:45.220Z","1.0.1":"2025-06-21T07:32:10.213Z"},"bugs":{"url":"https://github.com/api-craft/cache.git/issues"},"author":{"name":"P. Thamilselven"},"license":"MIT","homepage":"https://github.com/api-craft/cache.git#readme","keywords":["express","cache","middleware","redis","memcached","in-memory","api-craft","ecosystem"],"repository":{"type":"git","url":"git+https://github.com/api-craft/cache.git"},"description":"Unified caching middleware for Express.js supporting memory, Redis, and Memcached stores. Part of the API Craft ecosystem.","maintainers":[{"name":"tselven_me","email":"tselven13@gmail.com"}],"readme":"# @api-craft/cache\r\n\r\nUnified caching middleware for Express.js supporting **in-memory**, **Redis**, and **Memcached** cache stores.  \r\nPart of the [API Craft](https://github.com/yourusername/api-craft) ecosystem.\r\n\r\n---\r\n\r\n## Features\r\n\r\n- Cache all `GET` requests automatically with minimal setup\r\n- Support for multiple backends:\r\n  - In-memory (default, simple & fast for single server or dev)\r\n  - Redis (recommended for production & distributed caching)\r\n  - Memcached (high-performance distributed caching)\r\n- Flexible configuration with TTL, route prefix filtering, and exclusions\r\n- Automatic `X-Cache` response headers to help debugging cache hits/misses\r\n\r\n---\r\n\r\n## Installation\r\n\r\n```bash\r\npnpm add @api-craft/cache\r\n```\r\nor with npm\r\n```bash\r\nnpm install @api-craft/cache\r\n```\r\n\r\n***Note: `redis` and `memcached` clients are dependencies installed automatically.***\r\n\r\n## Usage\r\n``` js\r\nimport express from 'express';\r\nimport cacheMiddleware from '@api-craft/cache';\r\n\r\nconst app = express();\r\n\r\napp.use(cacheMiddleware({\r\n  storeType: 'redis', // 'memory' | 'redis' | 'memcached'\r\n  ttlSeconds: 120,    // Cache time-to-live in seconds\r\n  prefix: '/api/',    // Only cache routes starting with '/api/'\r\n  exclude: ['/api/auth'], // Exclude these route substrings from caching\r\n  redisOptions: {\r\n    url: 'redis://localhost:6379'\r\n  },\r\n  // memcachedServers: 'localhost:11211' // For Memcached store\r\n}));\r\n\r\napp.get('/api/data', (req, res) => {\r\n  // Simulate slow operation\r\n  setTimeout(() => {\r\n    res.json({ message: 'Hello from cached endpoint', time: new Date() });\r\n  }, 1000);\r\n});\r\n\r\napp.listen(3000, () => {\r\n  console.log('Server listening on http://localhost:3000');\r\n});\r\n```\r\n\r\n## Configuration Options\r\n\r\n| Option             | Type                                     | Default             | Description                                                                              |\r\n| ------------------ | ---------------------------------------- | ------------------- | ---------------------------------------------------------------------------------------- |\r\n| `storeType`        | `'memory'` \\| `'redis'` \\| `'memcached'` | `'memory'`          | Cache backend to use.                                                                    |\r\n| `ttlSeconds`       | `number`                                 | `60`                | Cache expiration time in seconds.                                                        |\r\n| `exclude`          | `string[]`                               | `[]`                | Array of URL substrings to exclude from caching.                                         |\r\n| `prefix`           | `string`                                 | `''`                | Cache only routes starting with this prefix.                                             |\r\n| `redisOptions`     | `Object`                                 | `{}`                | Options for Redis client (see [node-redis](https://github.com/redis/node-redis#options)) |\r\n| `memcachedServers` | `string` \\| `string[]`                   | `'localhost:11211'` | Memcached server(s) address(es).                                                         |\r\n\r\n## Response Headers\r\n\r\n`X-Cache`: HIT — Response served from cache\r\n\r\n`X-Cache`: MISS — Response generated fresh and cached\r\n\r\n## Notes\r\n\r\n- Redis and Memcached clients are bundled as dependencies and installed automatically.\r\n\r\n- Memcached does not support authentication by default.\r\n\r\n- In-memory caching is suitable for development or single-server environments.\r\n\r\n- For production, Redis or Memcached is recommended for distributed caching.\r\n\r\n- Only caches GET requests by default.\r\n\r\n## Contributing\r\n\r\nContributions, issues, and feature requests are welcome! Feel free to check issues page.\r\n\r\n## License\r\nMIT © 2025 Thamilselven\r\n\r\n## Links\r\n- [API Craft ecosystem](https://api-craft.tselven.com)","readmeFilename":"README.md"}