{"id":18954388,"url":"https://github.com/templarian/promisecache","last_synced_at":"2026-05-17T01:47:38.270Z","repository":{"id":66101961,"uuid":"119293043","full_name":"Templarian/promiseCache","owner":"Templarian","description":"TypeScript Promise Cache Dectorator","archived":false,"fork":false,"pushed_at":"2018-01-28T20:37:32.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-02T03:04:08.083Z","etag":null,"topics":["angular","promise","typescript"],"latest_commit_sha":null,"homepage":null,"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/Templarian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2018-01-28T20:03:37.000Z","updated_at":"2018-01-28T20:37:33.000Z","dependencies_parsed_at":"2023-03-03T14:30:59.246Z","dependency_job_id":null,"html_url":"https://github.com/Templarian/promiseCache","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Templarian/promiseCache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Templarian%2FpromiseCache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Templarian%2FpromiseCache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Templarian%2FpromiseCache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Templarian%2FpromiseCache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Templarian","download_url":"https://codeload.github.com/Templarian/promiseCache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Templarian%2FpromiseCache/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265069266,"owners_count":23706620,"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":["angular","promise","typescript"],"created_at":"2024-11-08T13:44:50.133Z","updated_at":"2026-05-17T01:47:33.251Z","avatar_url":"https://github.com/Templarian.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TypeScript promiseCache\n\nThe `promiseCache` dectorator and service allow an easy ability to apply caching for a method returning an async return.\n\nCaching promises can be useful when similar components are calling the same endpoint which can be common in larger forms or dropdown lists.\n\n## Overview\n\n- `promiseCache.decorator.ts` - The `@promiseCache()` dectorator allows caching of the entire method or based on exact parameters.\n- `promiseCache.service.ts` - Stores a cache dictionary that allows clearing of data. This could be extended easily to cache across browser sessions if needed.\n\nI will take pull requests on this repo. Mostly putting the code out there for others and for myself since I use it in a few locations.\n\n## Examples\n\n### Without Paramters\n\nThe easiest example is caching a basic `getItems` request.\n\n```TypeScript\n@PromiseCache()\nasync getItems(): Promise\u003cItem[]\u003e {\n  let res = await this.http.get\u003cItem\u003e('/api/items')\n    .toPromise();\n  return res.map(i =\u003e new Item().from(i)); // .from is a dto mapper\n}\n```\n\n### With Parameters\n\nExtending the example above with a basic search filter for a `term` paramters.\n\n```TypeScript\n@PromiseCache()\nasync getItems(@CacheParam term: string): Promise\u003cItem[]\u003e {\n  let res = await this.http.get\u003cItem\u003e('/api/items', {\n      params: {\n          term: term\n      }\n  }).toPromise();\n  return res.map(i =\u003e new Item().from(i)); // .from is a dto mapper\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftemplarian%2Fpromisecache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftemplarian%2Fpromisecache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftemplarian%2Fpromisecache/lists"}