{"id":44270417,"url":"https://github.com/tusharf5/runtime-memcache","last_synced_at":"2026-02-10T19:13:45.161Z","repository":{"id":42941823,"uuid":"234638514","full_name":"tusharf5/runtime-memcache","owner":"tusharf5","description":"runtime-memcache is a javascript key-value store for chunks of arbitrary data (strings, objects, numbers) from results of database calls, API calls, or etc. It supports many commonly used caching policies.","archived":false,"fork":false,"pushed_at":"2023-03-15T03:10:53.000Z","size":623,"stargazers_count":20,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-08-24T06:47:27.183Z","etag":null,"topics":["browser","cache","caching-strategies","javascript","lru","lru-cache","mru","nodejs","runtime","runtime-memcache","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/runtime-memcache","language":"JavaScript","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/tusharf5.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-17T21:18:12.000Z","updated_at":"2023-01-12T06:00:24.000Z","dependencies_parsed_at":"2023-02-08T08:16:07.092Z","dependency_job_id":null,"html_url":"https://github.com/tusharf5/runtime-memcache","commit_stats":null,"previous_names":[],"tags_count":25,"template":null,"template_full_name":null,"purl":"pkg:github/tusharf5/runtime-memcache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusharf5%2Fruntime-memcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusharf5%2Fruntime-memcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusharf5%2Fruntime-memcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusharf5%2Fruntime-memcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tusharf5","download_url":"https://codeload.github.com/tusharf5/runtime-memcache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusharf5%2Fruntime-memcache/sbom","scorecard":{"id":902914,"data":{"date":"2025-08-11","repo":{"name":"github.com/tusharf5/runtime-memcache","commit":"069f48603ab8228f197bec7ac132a5a631b65551"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 5 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"15 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq","Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488","Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j","Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T16:19:40.872Z","repository_id":42941823,"created_at":"2025-08-24T16:19:40.872Z","updated_at":"2025-08-24T16:19:40.872Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29313105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T17:48:59.043Z","status":"ssl_error","status_checked_at":"2026-02-10T17:45:37.240Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["browser","cache","caching-strategies","javascript","lru","lru-cache","mru","nodejs","runtime","runtime-memcache","typescript"],"created_at":"2026-02-10T19:13:44.316Z","updated_at":"2026-02-10T19:13:45.137Z","avatar_url":"https://github.com/tusharf5.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n   \u003ca href=\"https://github.com/tusharf5/runtime-memcache\"\u003e\u003cimg src=\"http://randojs.com/images/shapeShifterGray.gif\" alt=\"javascript cache\" height=\"60\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eruntime-memcache\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003eA no dependency, \u003cb\u003ehigh performance\u003c/b\u003e, near optimal javascript caching library\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n \u003ca href=\"https://github.com/tusharf5/runtime-memcache\"\u003e\n     \u003cimg src=\"https://img.shields.io/npm/l/runtime-memcache\" height=\"20\"/\u003e\n  \u003c/a\u003e\n \u003ca href=\"https://github.com/tusharf5/runtime-memcache\"\u003e\n     \u003cimg src=\"https://img.shields.io/npm/v/runtime-memcache\" height=\"20\"/\u003e\n  \u003c/a\u003e\n \u003ca href=\"https://github.com/tusharf5/runtime-memcache\"\u003e\n     \u003cimg src=\"https://img.shields.io/npm/dt/runtime-memcache\" height=\"20\"/\u003e\n  \u003c/a\u003e\n \u003ca href=\"https://github.com/tusharf5/runtime-memcache\"\u003e\n     \u003cimg src=\"https://img.shields.io/bundlephobia/minzip/runtime-memcache\" height=\"20\"/\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\u003cbr/\u003e\u003cbr/\u003e\n\nruntime-memcache is a caching library to store key-value cache store for small chunks of arbitrary data (strings, objects, numbers) from results of database calls, API calls, or etc. It is entirely written using Typescript and supports many commonly used caching policies.\n\nWhen creating a new cache store, you can specify the policy to evict items from the store. The default policy is `lru` (Least Recently Used)\n\nruntime-memcache provides flexible construction to create a cache with a combination of the following features:\n\n- size-based eviction when a maximum is exceeded based on frequency and recency\n- time-based expiration of entries, measured since last access or last write\n\n## Installation\n\n```shell\nnpm install --save runtime-memcache\n# or using yarn\nyarn add runtime-memcache\n```\n\n### Node Environment (ES6+ import/export)\n\n```javascript\nimport createStore from 'runtime-memcache';\n```\n\n### Node Environment (CJS)\n\n```javascript\nconst createStore = require('runtime-memcache');\n```\n\n### Browser (use as a script tag)\n\n```html\n\u003cscript src=\"https://unpkg.com/runtime-memcache@3.0.0/dist/umd/index.js\"\u003e\u003c/script\u003e\n\u003c!-- OR JUST --\u003e\n\u003cscript src=\"https://unpkg.com/runtime-memcache@3.0.0\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  // RMStore is globaly set\n  const store = new RMStore();\n\u003c/script\u003e\n```\n\n## API\n\nCalling the `createStore` function returns an object with the following properties.\n\n| Property        | Description                                      |\n| --------------- | ------------------------------------------------ |\n| `get(id)`       | Retrieves an item from the store                 |\n| `has(id)`       | Check if an item exists in the store             |\n| `set(id, data)` | Sets an item in the store                        |\n| `remove(id)`    | Removes an item from the store                   |\n| `size()`        | Returns the size of the item cache store         |\n| `keys()`        | Returns all the keys of the cache store as array |\n\n## Config\n\n`createStore` takes an optional config object as an argument with the following properties.\n\n| Property      | Description                                                                                           | Type                            | Default |\n| ------------- | ----------------------------------------------------------------------------------------------------- | ------------------------------- | ------- |\n| `timeToClear` | Time in **milliseconds** for which the store will keep an item when the policy is `timeout` or `tlru` | Number                          | 7200000 |\n| `policy`      | A Policy to evict items from the store                                                                | `timeout`, `lru`, `mru`, `tlru` | `lru`   |\n| `lruSize`     | Size of the cache store when the policy is `lru` or `tlru`                                            | Number                          | 500     |\n| `mruSize`     | Size of the cache store when the policy is `mru`                                                      | Number                          | 500     |\n\n## Caching Policies\n\nFollowing caching policies are supported.\n\n| Policy    | Name                           | Description                                                                                                                                                                      |\n| --------- | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `timeout` | Timeout                        | The items in the cache store will be automatically evicted after a fixed amount of time has elapsed since that item was set                                                      |\n| `lru`     | Least Recently Used            | This policy evicts the **least recently used** items when the store size is full                                                                                                 |\n| `tlru`    | Time Aware Least Recently Used | This policy evicts the **least recently used** items when the store size is full and also evict untouched items after a fixed amount of time has elapsed since that item was set |\n| `mru`     | Most Recently Used             | This policy evicts the **most recently used** items when the store size is full                                                                                                  |\n\n## Time Complexity\n\n| Policy  | Method                 | Complexity       |\n| ------- | ---------------------- | ---------------- |\n| timeout | `set`, `get`, `remove` | O(1), O(1), O(1) |\n| lru     | `set`, `get`, `remove` | O(1), O(1), O(1) |\n| tlru    | `set`, `get`, `remove` | O(1), O(1), O(1) |\n| mru     | `set`, `get`, `remove` | O(1), O(1), O(1) |\n\n## Usage\n\n### Typescript\n\n```typescript\nimport createStore, { Config } from 'runtime-memcache';\n\nconst config: Config = {\n  policy: 'lru',\n  lruSize: 300, // cache a maximum of 300 users at a given time\n};\n\ninterface User {\n  name: string;\n}\n\nconst userCache = createStore\u003cUser\u003e(config);\n\nasync function loginUser(userId: string) {\n  if (userCache.has(userId)) {\n    return userCache.get(userId);\n  }\n\n  const user: User = await UserService.getUser(userId);\n\n  userCache.set(userId, user);\n\n  return user;\n}\n```\n\n### Javascript\n\n```javascript\nimport createStore from 'runtime-memcache';\n\nconst config = {\n  policy: 'timeout',\n  timeToClear: 7200000, // 2 hours\n};\n\ntype Keys = 'key1' | 'key2';\n\nconst store = createStore(config);\n\nstore.set('key1', { name: 'name' }); // store the object and associate it with the provided key\n\nstore.get('key1'); // retrieves the object associated with this key\n\nstore.has('key1'); // returns true\n\nstore.size(); // returns 1\n\nstore.keys(); // returns ['key1']\n\nstore.remove('key1'); // deletes the object associated with this key\n```\n\n## NPM Script Commands\n\n- `npm run test` -- Runs tests, lint and build.\n- `npm run lint` -- Runs ESLint.\n- `npm run format` -- Reformats all of the `.ts` and `.tsx` files with Prettier.\n- `npm run build` -- Regenerates `dist` folder that gets included into NPM module.\n\n## Under The Hood\n\nruntime-memcache uses a combination of modified doubly-linked lists and hashmap data structures to achieve O(1) search-time complexity for all the methods.\n\n## Todos\n\n- \u003cs\u003eTimeout Policy (TR)\u003c/s\u003e\n- \u003cs\u003eLeast Recently Used Policy (LRU)\u003c/s\u003e\n- \u003cs\u003eMost Recently Used Policy (MRU)\u003c/s\u003e\n- Least Frequently Used Policy (LFU)\n- \u003cs\u003eTime Aware Least Recently Used Policy (TLRU)\u003c/s\u003e\n- Random Eviction Policy (RR)\n- Add a warmup period for new items\n\nFor more information on caching policies read [this](https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftusharf5%2Fruntime-memcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftusharf5%2Fruntime-memcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftusharf5%2Fruntime-memcache/lists"}