{"id":15823332,"url":"https://github.com/slippyex/yet-another-redis-cache","last_synced_at":"2025-04-01T16:30:48.611Z","repository":{"id":65844434,"uuid":"601068786","full_name":"slippyex/yet-another-redis-cache","owner":"slippyex","description":"Yet another redis cache is, as the name implies, a redis cache implementation. But with the additional ability to bulk operate on cache keys (get/set/delete)","archived":false,"fork":false,"pushed_at":"2023-07-10T23:30:44.000Z","size":643,"stargazers_count":4,"open_issues_count":8,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-06T08:07:55.165Z","etag":null,"topics":["cache","caching","dependencies","redis","typescript","yarn"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/slippyex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-13T09:53:52.000Z","updated_at":"2023-02-22T07:32:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"79b61245-e938-4e15-90c7-c1aef4411806","html_url":"https://github.com/slippyex/yet-another-redis-cache","commit_stats":{"total_commits":61,"total_committers":3,"mean_commits":"20.333333333333332","dds":0.3114754098360656,"last_synced_commit":"2fd0ce3e091014084cbdaa2e0be587953d0eea5d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slippyex%2Fyet-another-redis-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slippyex%2Fyet-another-redis-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slippyex%2Fyet-another-redis-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slippyex%2Fyet-another-redis-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slippyex","download_url":"https://codeload.github.com/slippyex/yet-another-redis-cache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246620326,"owners_count":20806752,"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","caching","dependencies","redis","typescript","yarn"],"created_at":"2024-10-05T08:08:40.628Z","updated_at":"2025-04-01T16:30:48.303Z","avatar_url":"https://github.com/slippyex.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![GitHub package.json version](https://img.shields.io/github/package-json/v/slippyex/yet-another-redis-cache)\n![NPM](https://img.shields.io/npm/l/yet-another-redis-cache)\n[![CircleCI](https://dl.circleci.com/status-badge/img/gh/slippyex/yet-another-redis-cache/tree/main.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/slippyex/yet-another-redis-cache/tree/main)\n[![codecov](https://codecov.io/gh/slippyex/yet-another-redis-cache/branch/main/graph/badge.svg?token=B1NTASVMHG)](https://codecov.io/gh/slippyex/yet-another-redis-cache)\n# YET ANOTHER REDIS CACHE\n\nAs the name implies, this is yet another (booooring) Redis-backed cache. However, this is not completely true.\nIn fact, it has some useful, not seen, functionality which I wanted to leverage for my own projects.\nAnd since I didn't find the features, I decided to release this as another npm package, trying to \ngive back to the OS community.\n\n### Documentation\n[TSDOC pages](https://slippyex.github.io/yet-another-redis-cache/)\n\n### Intro\nSo, long story short, the purpose of this package is ... guess what ... caching. Therefore, you will \nfind the regular get/set methods plus some minimal options. Details to follow below.\n\nThe real interesting part comes, when you want to add (or get) more than just one value at once.\n\nLet's say, I want to cache an arbitary amount of keys/vals at once. \n\nFor that I can now use `getBulk` and `setBulk` which allow me to add or retrieve these in one Redis backend call.\n\n### Getting started\n```bash\nyarn add yet-another-redis-cache\n```\n\n### Features\n- Works out of the box\n- provides regular cache functionality like get, set, delete\n- provides bulk cache functionality getBulk, setBulk, deleteBulk (one Redis transaction)\n- flexible expiration of keys by either setting them on the instantiation or per setter\n\n### Usage\n```typescript\n  // create cache instance with a default of 5 seconds ttl per entry and a group prefix \"example\"\n  const redisCache = new RedisCache(process.env.REDIS_URL, { groupKeyPrefix: 'example', ttl: 5 });\n  const valuesToCache = {\n      \"identifier-1\": \"abdcef\",\n      \"identifier-2\": \"bcdef1\",\n      \"identifier-3\": \"cdef12\",\n      \"identifier-4\": \"99aabb\"\n  };\n  await redisCache.setBulk(valuesToCache);\n```\nThe above code snippet will run in one Redis transaction. When a new request with a (sub-)set of the above keys \ncomes in, we can create a single-transaction cache lookup with the following code\n```typescript\n  const cachedResults = await redisCache.getBulk(['identifier-2', 'identifier-3', 'identifier-10']);\n```\nThe `cachedResults` will look like the following:\n```json\n  {\n      \"identifier-2\": \"bcdef1\",\n      \"identifier-3\": \"cdef12\",\n      \"identifier-10\": null\n  }\n```\nAllowing you to retrieve the result for `identifier-10`, cache and return the whole set\n\n\nBesides the two bulk getter/setter, you can also use the regular get/set like\n\n```typescript\n  await redisCache.set('regular-key', {'test': true});\n  ...\n  ...\n  const cachedValue: { test: boolean } = await redisCache.get('regular-key');\n```\n\nAdditionally to the getter/setter, we can also `delete(key: string)` and `deleteBulk(keys: string[])` explicit elements from the cache or get a list of keys with a certain pattern by calling `await redisCache.keys('my-pattern*')` for example.\n\n### Run tests\n```bash\nyarn test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslippyex%2Fyet-another-redis-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslippyex%2Fyet-another-redis-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslippyex%2Fyet-another-redis-cache/lists"}