{"id":20046376,"url":"https://github.com/aneldev/dyna-cache","last_synced_at":"2026-05-06T04:31:06.651Z","repository":{"id":57217571,"uuid":"93780125","full_name":"aneldev/dyna-cache","owner":"aneldev","description":"Cache with controlled memory consumption","archived":false,"fork":false,"pushed_at":"2023-01-13T07:54:14.000Z","size":379,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-10T12:59:27.505Z","etag":null,"topics":["cache","cache-control","javascript","memory","nodejs","typescript","universal"],"latest_commit_sha":null,"homepage":null,"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/aneldev.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}},"created_at":"2017-06-08T18:32:18.000Z","updated_at":"2023-01-12T09:49:51.000Z","dependencies_parsed_at":"2023-02-09T15:01:56.367Z","dependency_job_id":null,"html_url":"https://github.com/aneldev/dyna-cache","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/aneldev/dyna-cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneldev%2Fdyna-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneldev%2Fdyna-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneldev%2Fdyna-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneldev%2Fdyna-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aneldev","download_url":"https://codeload.github.com/aneldev/dyna-cache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneldev%2Fdyna-cache/sbom","scorecard":{"id":195569,"data":{"date":"2025-08-11","repo":{"name":"github.com/aneldev/dyna-cache","commit":"38443808c462e0386bc0728e6b841186023885c8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"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":"Code-Review","score":0,"reason":"Found 0/25 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":"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":"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 6 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":"40 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-qwcr-r2fm-qrc7","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc","Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx","Warn: Project is vulnerable to: GHSA-x3cc-x39p-42qx","Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc","Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27","Warn: Project is vulnerable to: GHSA-4www-5p9h-95mh","Warn: Project is vulnerable to: GHSA-9gqv-wp59-fq42","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-76c9-3jph-rj3q","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w","Warn: Project is vulnerable to: GHSA-566m-qj78-rww5","Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-44c6-4v22-4mhx","Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch","Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j","Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986","Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6","Warn: Project is vulnerable to: GHSA-4v9v-hfq4-rm2v","Warn: Project is vulnerable to: GHSA-9jgg-88mc-972h","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"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-16T21:46:09.496Z","repository_id":57217571,"created_at":"2025-08-16T21:46:09.496Z","updated_at":"2025-08-16T21:46:09.496Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32678567,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-06T02:33:58.958Z","status":"ssl_error","status_checked_at":"2026-05-06T02:33:39.611Z","response_time":117,"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":["cache","cache-control","javascript","memory","nodejs","typescript","universal"],"created_at":"2024-11-13T11:23:22.778Z","updated_at":"2026-05-06T04:31:06.594Z","avatar_url":"https://github.com/aneldev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# DynaCache v3\n\nCaches something and provides it immediately.\n\nPreload, refresh features out of the box.\n\n# createDynaCache\n\nThis factory function creates another function that uses the cache behind this.\n\n## Example\n\nSuppose we have this interface of articles\n```\ninterface ITestArticle {\n  title: string;\n  body: string;\n}\n```\n\nAnd this api method that loads the articles from the backend\n\n```\nconst apiLoadArticles = async (args: {lang: string, group: string}): Promise\u003cITestArticle[]\u003e =\u003e [];\n```\n\nLet's make api method cacheable version of it\n\n```\nconst apiLoadArticlesCacheEngine = createDynaCache({\n  load: apiLoadArticles,\n  expireAfterMinutes: 10,\n});\n```\n\nThe `apiLoadArticlesCacheEngine` is na object, with the `load(args: TArgs)` method that returns data.\n\nThanks to typescript, the function has all types obtained from the `load` method, for the args and for the output.\nSo we don't have to define anything to the generics of the `createDynaCache`.\n\n**Let's use it**\n```\n\napiLoadArticlesCacheEngine.load({lang: 'en', group: 'fashion'})     // We pass the object as we do with the apiLoadArticles\n  .then(articles =\u003e {\n    // We have types articles here\n    articles.forEach(article =\u003e {\n      console.log('Title', article.title);\n    });\n  });\n```\n\n## Configuration object of the `createDynaCache`\n\n```\ninterface ICreateDynaCacheConfig\u003cTArgs, TData, \u003e {\n  load: (args: TArgs) =\u003e Promise\u003cTData\u003e; // The load operation\n  expireAfterMinutes?: number;            // When the cache expires, undefined for none\n  preload?: boolean;                      // Preload the data on start\n  refreshEveryMinutes?: number;           // Refresh the data silently on background\n}\n```\n\n## Invalidate the cache\n\nTo invalidate the cache (to clear the content of the cache) call the `invalidate()`\n\n`apiLoadArticlesCacheEngine.invalidate();`\n\n\n## Don't forget to free() it!\n\nCache keeps resources for refreshing, etc.\n\nIf you are going to free the owner of it, your have to call the `.free()` also!\n\nJust `apiLoadArticlesCacheEngine.free()`.\n\n## How does it works internally?\n\nThe `apiLoadArticlesCacheEngine` creates internally small caches for each different `args`.\n\nIf you ask the same args, then the cached version will be served.\n\n\n# DynaCache\n\nThis is how to create a DynaCache class.\n\n## Config\n```\n interface IDynaCacheConfig\u003cTData\u003e {\n  load: () =\u003e Promise\u003cTData\u003e;       // The load operation\n\n  expireAfterMinutes?: number;      // When the cache expires, undefined for none\n  preload?: boolean;                // Preload the data on start\n  refreshEveryMinutes?: number;     // Refresh the data silently on background\n  onLoad?: (data: TData) =\u003e void;   // Called when the data are loaded for any reason\n}\n```\n\n## Methods\n\n- `load(): Promise\u003cTData\u003e` load from cache or from source if it is not yet cached\n- `loadFresh(): Promise\u003cTData\u003e` load fresh data (not from cache)\n- `invalidate(): void` clear the cache, all further loads will be new\n- `free(): void` destroy the cache (cleans up auto refresh cache)\n\n## Properties\n\n- `get size(): number` returns the size of the cache in bytes\n- `get loadedAt(): number` timestamp when the last load took place\n- `get lastUsedAt(): number` timestamp when the cache read last time\n- `get loadCount(): number` how many the cache was updated\n- `get lastError(): any` last load error\n\n## Example\n```\n// Factory function that create a DynaCache with specific args and api method\n// This function just connects that arguments with the api method\nconst createLoadArticlesCache = (lang: string, group: string) =\u003e\n  new DynaCache({\n    expireAfterMinutes: 10,\n    load: () =\u003e apiLoadArticles(lang, group),\n  });\n\n// Lets create a cache for the epi\nconst loadArticlesCache = createLoadArticlesCache('en', 'fashion');\n\n// Lets use it\nloadArticlesCache.load(); // The return is always up to date and fast\n\n// Don't forget to free() it to avoid memory leaks!\n// This is needed when `expireAfterMinutes` or `refreshEveryMinutes`\nloadArticlesCache.free();\n// Note, now you cannot use it anymore\n```\n\n# Change log\n\n## v3\n\nV3 is totally different approach than V2.\n\nV3 offers plus\n\n- preload\n- refresh\n- cache factory (cache key by args object)\n- simpler code (1/4 of the previous one)\n\n## v2\n\nFor v2 open [this](https://github.com/aneldev/dyna-cache/tree/v2.0.1) page.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faneldev%2Fdyna-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faneldev%2Fdyna-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faneldev%2Fdyna-cache/lists"}