handle cache cleanup in db
Some checks failed
Build / Build NPM Project (push) Successful in 40s
Build / Publish Documentation (push) Failing after 5s
Build / Tag Version (push) Successful in 8s

This commit is contained in:
2025-07-14 01:00:34 -04:00
parent 035a1d35cb
commit 1ab8e6424b
2 changed files with 4 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@ztimson/utils", "name": "@ztimson/utils",
"version": "0.26.6", "version": "0.26.7",
"description": "Utility library", "description": "Utility library",
"author": "Zak Timson", "author": "Zak Timson",
"license": "MIT", "license": "MIT",

View File

@ -80,7 +80,9 @@ export class Cache<K extends string | number | symbol, T> {
if(persists.storage?.database != undefined) { if(persists.storage?.database != undefined) {
(<Database>persists.storage).createTable({name: persists.key, key: <string>this.key}).then(table => { (<Database>persists.storage).createTable({name: persists.key, key: <string>this.key}).then(table => {
if(key) { if(key) {
table.set(this.get(key), key); const value = this.get(key);
if(value != null) table.set(value, key);
else table.delete(key);
} else { } else {
table.clear(); table.clear();
this.all().forEach(row => table.add(row)); this.all().forEach(row => table.add(row));