{"id":20678601,"url":"https://github.com/v-core9/v_core_cache","last_synced_at":"2026-01-28T13:36:13.754Z","repository":{"id":37859334,"uuid":"482215711","full_name":"V-core9/v_core_cache","owner":"V-core9","description":"Fast and simple Cache for Node and Web.","archived":false,"fork":false,"pushed_at":"2024-11-02T13:33:38.000Z","size":231,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main_index","last_synced_at":"2025-03-29T13:35:21.483Z","etag":null,"topics":["cache","caching","expire","nodejs","web"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/v_core_cache","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/V-core9.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}},"created_at":"2022-04-16T09:50:17.000Z","updated_at":"2024-02-06T01:16:32.000Z","dependencies_parsed_at":"2024-02-06T02:28:06.747Z","dependency_job_id":"d337ffe4-ec16-40d8-bf58-0abcbf323d14","html_url":"https://github.com/V-core9/v_core_cache","commit_stats":{"total_commits":38,"total_committers":1,"mean_commits":38.0,"dds":0.0,"last_synced_commit":"aa2e9b2bcc5d1c0aa3d6f4624d4c33e864c5dc90"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/V-core9%2Fv_core_cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/V-core9%2Fv_core_cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/V-core9%2Fv_core_cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/V-core9%2Fv_core_cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/V-core9","download_url":"https://codeload.github.com/V-core9/v_core_cache/tar.gz/refs/heads/main_index","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249811835,"owners_count":21328872,"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","expire","nodejs","web"],"created_at":"2024-11-16T21:21:08.694Z","updated_at":"2026-01-28T13:36:13.720Z","avatar_url":"https://github.com/V-core9.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# v_core_cache\n\nSimple Cache Solution for Node and Web.\n\nSections:\n\n1. 📑 How to use\n2. 🚗 Functions and Methods\n3. 🎪 Events\n4. ➰ Auto Cleanup Expired\n5. ❌ Deleted / Removed\n\n___\n\n## 📑 How to use\n\n    const { V_Core_Cache } = require('v_core_cache');\n    const cache = new V_Core_Cache();\n\n    // OR\n\n    const { createCache } = require('v_core_cache');\n    const cache = createCache();\n\n## 🚗 Functions and Methods\n\n### 1. Get Item Value\n\n    await cache.get(key)  //\u003e anything you put in\n    cache.getSync(key)\n\n### 2. Get Whole Cache\n\nReturns all cache.\n\n    cache.getAll() //\u003e object\n\n### 3. Size of Cache\n\nReturns the approximate size of the cache in bytes.\n\n    await cache.size();  //\u003e 1507114 \n    cache.sizeSync();\n\n### 4. Has Item?\n\nReturns true if the key exists in the cache and is not expired.\n\n    cache.has(key)   \n\n### 5. Set Item\n\nSet/Create/Update an item in the cache. Will overwrite existing item.\n\n    await cache.set(key, data, expires?)\n    cache.setSync(key, data, expires?)  \n\n### 6. Purge cache\n\nReturns true if cache was successfully purged. Otherwise, returns false if cache is already empty.\n\n    await cache.purge()\n\n### 7. Delete item from cache\n\n    await cache.del(key);  //\u003e true/false\n    cache.delSync(key);\n\n### 8. Stats\n\nReturns stats about the cache.\n\n    cache.stats() //\u003e { hits: 156, misses: 15, count: 33, size: 1507114 }\n\n### 9. Purge Stats\n\nThis basically just resets counters for hits and misses.\n\n    cache.purgeStats()  //\u003e { hits: 0, misses: 0, count: 33, size: 1507114 }\n\n### 10. Get Item Expire Time\n\nReturns the time in milliseconds when the item will expire.\n\n    cache.getExpire(key); //\u003e 150123456789 [ Date.now() + expires]\n\n### 11. Cleanup Expired Items\n\nReturns the number of expired items removed.\n\n    await cache.cleanup(); \n\n### 12. Count Items\n\nReturns the number of items in cache.\n\n    await cache.count();\n    cache.countSync(); \n\n___\n\n## 🎪 Events\n\n## Management\n\n### 1. Add Event Listener\n\n    cache.addListener(\"set\", (data) =\u003e console.log(data));\n    // or\n    cache.on(\"set\", (data) =\u003e console.log(data));\n\n### 2. Remove Event Listener\n\n    cache.removeListener(\"set\", (data) =\u003e console.log(data));\n    // or\n    cache.off(\"set\", (data) =\u003e console.log(data));\n\n### 3. Prepend Event Listener\n\n    cache.prependListener(\"set\", (data) =\u003e console.log(data));\n    // or\n    cache.pre(\"set\", (data) =\u003e console.log(data));\n\n### 4. Get Registered EventNames\n\n    console.log(cache.eventNames());\n\n### 5. Remove All Listeners\n\nRemoves all registered listeners for a single event\n\n    cache.removeAllListeners('set')\n\n### 6. Purge All Listeners\n\nRemoves all registered listeners for all registered events\n\n    cache.purgeAllListeners()\n\n## Available events\n\n### 1. SET\n\nReturns {key, value} pair.\n\n    cache.on('set', (item) =\u003e console.log(item.key, item.value))\n\n### 1.2 set with key\n\nIn this case we are returning the value only.\n\n    cache.on('set/{key}', (value) =\u003e console.log(value))\n\n### 2. GET\n\n    cache.on('get', (item) =\u003e console.log(data)) //\u003e { key, value } - value can be undefined \n\n### 3. HIT\n\n    cache.on('hit', (item) =\u003e console.log(item)) //\u003e { key, value } \n\n### 4. MISS\n\n    cache.on('miss', (item) =\u003e console.log(item)) //\u003e { key } \n\n### 5. PURGE\n\n    cache.on('purge', (status) =\u003e console.log(status)) //\u003e true/false - can return false if already empty\n\n### 6. PURGE_STATS\n\n    cache.on('purge_stats', (data) =\u003e console.log(data)) //\u003e { hits, misses, count, size } - returns stats after purging them.\n\n### 6. cleanup\n\nreturns number of affected items\n\n    cache.on('cleanup', (data) =\u003e console.log(data)) //\u003e number \n\n### 6. addListener\n\nNew listener added\n\n    cache.on('addListener', (data) =\u003e console.log(data)) \n\n### 6. removeListener\n\nRemoved event listener\n\n    cache.on('addListener', (data) =\u003e console.log(data)) \n\n___\n\n## ➰ Auto Cleanup Expired\n\n    const V_Core_Cache = require('v_core_cache');\n    const cache = new V_Core_Cache({ cleanInterval: 250 }); // Number in milliseconds \n\n\u003e **NOTE**: When using autoCleanup you should stop the cleanup interval by calling `cache.stopCleanup()`\n\n___\n\n\n## **✅ Tests and Coverage with Jest**\n\n![Test and Coverage with Jest](coverage.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv-core9%2Fv_core_cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fv-core9%2Fv_core_cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv-core9%2Fv_core_cache/lists"}