{"_id":"@cachehub/upstash-redis-cache","_rev":"3-ac10f1b6e55570f9d2307795b6c548f8","name":"@cachehub/upstash-redis-cache","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@cachehub/upstash-redis-cache","version":"1.0.0","_id":"@cachehub/upstash-redis-cache@1.0.0","maintainers":[{"name":"dmitryrechkin","email":"rechkin@gmail.com"}],"dist":{"shasum":"f186fac86ce211b83ea98a8db8079b4db4913552","tarball":"https://registry.npmjs.org/@cachehub/upstash-redis-cache/-/upstash-redis-cache-1.0.0.tgz","fileCount":17,"integrity":"sha512-9c4rdZs3+cyk+YvMFP3KTr2lrjK0RaeBRDugUrY4tSjX9W8RkHKVDbPQtW4vOvxHHPBcRr49pg5wS8ySv6A2lg==","signatures":[{"sig":"MEQCIHziYTSpXeCpnty0lE7wlxT9yYm1dG/VmduDVWJbqNWsAiAp4ZOO5bDerLwITy89A/TEl4B9W5siGZqQNPuBZ8/l4g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":44276},"main":"dist/index.js","type":"module","_from":"file:cachehub-upstash-redis-cache-1.0.0.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint .","test":"vitest run","build":"shx rm -rf dist && tsc && fix-esm-import-path dist","check":"tsc --noEmit","format":"eslint --fix .","package:publish":"pnpm publish --access public"},"_npmUser":{"name":"dmitryrechkin","email":"rechkin@gmail.com"},"_resolved":"/private/var/folders/67/qcbb1q556vbfzygwbkm5glcr0000gn/T/930a1c641384e9e76776efc842deb21d/cachehub-upstash-redis-cache-1.0.0.tgz","_integrity":"sha512-9c4rdZs3+cyk+YvMFP3KTr2lrjK0RaeBRDugUrY4tSjX9W8RkHKVDbPQtW4vOvxHHPBcRr49pg5wS8ySv6A2lg==","_npmVersion":"10.8.2","description":"Upstash Redis cache implementation for CacheHub.","directories":{},"_nodeVersion":"22.5.1","dependencies":{"@cachehub/core":"1.0.0","@upstash/redis":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"shx":"^0.3.4","dotenv":"^16.4.5","eslint":"^8.0.0","vitest":"^0.24.5","typescript":"^5.5.3","tsconfig-paths":"^4.2.0","fix-esm-import-path":"^1.0.1","eslint-plugin-unused-imports":"^3.0.0","@dmitryrechkin/eslint-standard":"^1.0.7"},"_npmOperationalInternal":{"tmp":"tmp/upstash-redis-cache_1.0.0_1735441059925_0.3007029254865996","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@cachehub/upstash-redis-cache","version":"1.0.1","_id":"@cachehub/upstash-redis-cache@1.0.1","maintainers":[{"name":"dmitryrechkin","email":"rechkin@gmail.com"}],"dist":{"shasum":"0ef00e7f2cfa4dd9f1cd8796fb5b8cfd46805ef4","tarball":"https://registry.npmjs.org/@cachehub/upstash-redis-cache/-/upstash-redis-cache-1.0.1.tgz","fileCount":17,"integrity":"sha512-zCK6pvJxYRGgZGXG5sLQMSFDj4Qxgm4mEgSnStzsCp20XbCwNIcrl5UE9JWy39V8R8gNJnXRE0Kb/uWADyX8Yg==","signatures":[{"sig":"MEUCIQCagY1CXFIsF/iQnGzGwSJ4XrAKN/S/jYbA2wqTr2KyKwIgC3cQGXxPgWfhc4n+okucG4tpq3kV2BbDK6V0JdKEwc8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":44797},"main":"dist/index.js","type":"module","_from":"file:cachehub-upstash-redis-cache-1.0.1.tgz","types":"dist/index.d.ts","scripts":{"lint":"eslint .","test":"vitest run","build":"shx rm -rf dist && tsc && fix-esm-import-path dist","check":"tsc --noEmit","format":"eslint --fix .","package:publish":"pnpm publish --access public"},"_npmUser":{"name":"dmitryrechkin","email":"rechkin@gmail.com"},"_resolved":"/private/var/folders/67/qcbb1q556vbfzygwbkm5glcr0000gn/T/e79662cde6cb6f970a382c9b90aa894a/cachehub-upstash-redis-cache-1.0.1.tgz","_integrity":"sha512-zCK6pvJxYRGgZGXG5sLQMSFDj4Qxgm4mEgSnStzsCp20XbCwNIcrl5UE9JWy39V8R8gNJnXRE0Kb/uWADyX8Yg==","_npmVersion":"10.8.2","description":"Upstash Redis cache implementation for CacheHub.","directories":{},"_nodeVersion":"22.5.1","dependencies":{"@cachehub/core":"1.0.1","@upstash/redis":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"shx":"^0.3.4","dotenv":"^16.4.5","eslint":"^8.0.0","vitest":"^0.24.5","typescript":"^5.5.3","tsconfig-paths":"^4.2.0","fix-esm-import-path":"^1.0.1","eslint-plugin-unused-imports":"^3.0.0","@dmitryrechkin/eslint-standard":"^1.0.7"},"_npmOperationalInternal":{"tmp":"tmp/upstash-redis-cache_1.0.1_1735493484936_0.4855319487099865","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@cachehub/upstash-redis-cache","type":"module","version":"1.0.2","main":"dist/index.js","types":"dist/index.d.ts","devDependencies":{"@dmitryrechkin/eslint-standard":"^1.0.7","fix-esm-import-path":"^1.0.1","dotenv":"^16.4.5","eslint":"^8.0.0","eslint-plugin-unused-imports":"^3.0.0","tsconfig-paths":"^4.2.0","typescript":"^5.5.3","vitest":"^0.24.5","shx":"^0.3.4"},"dependencies":{"@upstash/redis":"^1.0.0","@cachehub/core":"1.0.2"},"scripts":{"lint":"eslint .","format":"eslint --fix .","test":"vitest run","check":"tsc --noEmit","build":"shx rm -rf dist && tsc && fix-esm-import-path dist","package:publish":"pnpm publish --access public"},"_id":"@cachehub/upstash-redis-cache@1.0.2","description":"Upstash Redis cache implementation for CacheHub with hybrid string and TypeCacheKey support.","_integrity":"sha512-3v6+T+TKC5NJ81AqUi2bvcndRRL9g+Twfo00GZNoBIA+cA6YTE6dXSMhmR8QTXngibot8W19eofvPsH4ihAbtQ==","_resolved":"/private/var/folders/67/qcbb1q556vbfzygwbkm5glcr0000gn/T/92ea52e7c6d4e12160c2bc9d36b8b74c/cachehub-upstash-redis-cache-1.0.2.tgz","_from":"file:cachehub-upstash-redis-cache-1.0.2.tgz","_nodeVersion":"23.11.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-3v6+T+TKC5NJ81AqUi2bvcndRRL9g+Twfo00GZNoBIA+cA6YTE6dXSMhmR8QTXngibot8W19eofvPsH4ihAbtQ==","shasum":"0416b3c50dab408294372948670c0cfdb9835077","tarball":"https://registry.npmjs.org/@cachehub/upstash-redis-cache/-/upstash-redis-cache-1.0.2.tgz","fileCount":17,"unpackedSize":53063,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFEFlLzUeNV+EwKZIN0jCHZFzk2jI1APs/kOX5zUvwFHAiAveoNuJJ286NTwktKs+NCby1PVJ2lDXn+sFGOwDNyqxA=="}]},"_npmUser":{"name":"dmitryrechkin","email":"rechkin@gmail.com","actor":{"name":"dmitryrechkin","email":"rechkin@gmail.com","type":"user"}},"directories":{},"maintainers":[{"name":"dmitryrechkin","email":"rechkin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/upstash-redis-cache_1.0.2_1751687451337_0.7091084525639304"},"_hasShrinkwrap":false}},"time":{"created":"2024-12-29T02:57:39.816Z","modified":"2025-07-05T03:50:51.752Z","1.0.0":"2024-12-29T02:57:40.115Z","1.0.1":"2024-12-29T17:31:25.184Z","1.0.2":"2025-07-05T03:50:51.533Z"},"description":"Upstash Redis cache implementation for CacheHub with hybrid string and TypeCacheKey support.","maintainers":[{"name":"dmitryrechkin","email":"rechkin@gmail.com"}],"readme":"# @cachehub/upstash-redis-cache\n\nUpstash Redis cache implementation for CacheHub with hybrid string and TypeCacheKey support.\n\n## Installation\n\n```bash\npnpm add @cachehub/upstash-redis-cache @upstash/redis\n```\n\n## Usage\nTo use the Upstash Redis cache adapter in your application, follow these steps:\n\n1.  Import the Upstash Redis cache package to register it with the factory. For example:\n    ```typescript\n    import '@cachehub/upstash-redis-cache';\n    ```\n2.  Create a cache instance using the factory.\n3.  Use the cache instance to set, get, delete, and check cache entries.\n\n```typescript\nimport '@cachehub/upstash-redis-cache';\nimport { UpstashRedisCacheFactory } from '@cachehub/upstash-redis-cache';\n\nconst factory = new UpstashRedisCacheFactory();\nconst cache = await factory.createCache({\n  CACHE_TYPE: 'upstash-redis-cache',\n  REDIS_URL: process.env.REDIS_URL!,\n  REDIS_TOKEN: process.env.REDIS_TOKEN!,\n});\n\n// Set and get primitive types\nawait cache.set<string>('stringKey', 'value');\nconst stringValue = await cache.get<string>('stringKey');\n\nawait cache.set<number>('numberKey', 42);\nconst numberValue = await cache.get<number>('numberKey');\n\nawait cache.set<boolean>('booleanKey', true);\nconst booleanValue = await cache.get<boolean>('booleanKey');\n\n// Set and get complex objects\ninterface User {\n  id: number;\n  name: string;\n  email: string;\n}\n\nconst user: User = {\n  id: 1,\n  name: 'John Doe',\n  email: 'john@example.com'\n};\n\nawait cache.set<User>('userKey', user);\nconst userValue = await cache.get<User>('userKey');\n\n// Set and get arrays\nawait cache.set<string[]>('arrayKey', ['a', 'b', 'c']);\nconst arrayValue = await cache.get<string[]>('arrayKey');\n\n// Basic cache operations\nawait cache.delete('key');\nconst exists = await cache.has('key');\n```\n\n### TypeCacheKey Support\n\nThe adapter supports structured cache keys for advanced scenarios:\n\n```typescript\nimport type { TypeCacheKey } from '@cachehub/core';\n\n// Using structured cache keys\nconst licenseKey: TypeCacheKey = {\n  namespace: 'license',\n  id: 'ABC-123',\n  context: {\n    action: 'activation',\n    domain: 'example.com',\n    ipAddress: '192.168.1.1'\n  }\n};\n\n// Store with structured key\nawait cache.set(licenseKey, { token: 'xyz789', expires: Date.now() + 3600000 });\n\n// Retrieve with structured key\nconst licenseData = await cache.get(licenseKey);\n\n// Pattern deletion - delete all cache entries for license ABC-123\nawait cache.delete({\n  namespace: 'license',\n  id: 'ABC-123'\n  // Omitting context deletes ALL entries matching namespace and id\n});\n\n// Delete all license entries\nawait cache.delete({\n  namespace: 'license'\n  // Omitting id deletes ALL entries in the namespace\n});\n```\n\n### Pattern Deletion Support\n\nThe UpstashRedisCache provides **native pattern deletion** using Redis SCAN operations:\n\n**✅ All Deletion Patterns Supported:**\n```typescript\n// Exact key deletion with TypeCacheKey\nawait cache.delete({ \n  namespace: 'license', \n  id: 'ABC-123',\n  context: { action: 'activation', domain: 'example.com' }\n});\n\n// Namespace + ID deletion (deletes all contexts for that ID)\nawait cache.delete({ \n  namespace: 'license', \n  id: 'ABC-123' \n});\n\n// Partial context deletion (deletes all entries matching partial context)\nawait cache.delete({ \n  namespace: 'license', \n  context: { action: 'activation' }  // Deletes all activations regardless of ID\n});\n\n// Namespace-only deletion (deletes all entries in namespace)\nawait cache.delete({ \n  namespace: 'license' \n});\n\n// String key deletion\nawait cache.delete('exact-string-key');\n```\n\n**How It Works:**\n- **Redis SCAN**: Uses native Redis SCAN operations with MATCH patterns\n- **Immediate Consistency**: Deletions complete immediately using DEL command\n- **Efficient Batching**: Processes keys in batches of 100 for optimal performance\n- **Native Redis Operations**: Leverages Redis cluster-safe operations\n\n### Key Serialization\n\nTypeCacheKey objects are automatically serialized to deterministic strings:\n- `{ namespace: 'license', id: '123' }` → `'license|123'`\n- `{ namespace: 'license', id: '123', context: { action: 'activation' } }` → `'license|123|action:activation'`\n- Context keys are sorted alphabetically for consistency\n\n## Configuration\n\nThe Upstash Redis cache requires the following configuration:\n\n```typescript\ninterface TypeUpstashRedisCacheConfig {\n  /**\n   * The Redis URL\n   */\n  REDIS_URL: string;\n\n  /**\n   * The Redis token\n   */\n  REDIS_TOKEN: string;\n\n  /**\n   * Optional prefix for cache keys\n   */\n  keyPrefix?: string;\n}\n```\n\n## Testing\n\nTo run the tests, create a `.env` file with your Upstash Redis credentials:\n\n```env\nREDIS_URL=your_redis_url\nREDIS_TOKEN=your_redis_token\n```\n\nThen run:\n\n```bash\npnpm test\n```\n","readmeFilename":"README.md"}