@bejibun/cache 0.1.15 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  ---
5
5
 
6
+ ## [v0.1.16](https://github.com/crenata/bejibun-cache/compare/v0.1.15...v0.1.16) - 2025-12-15
7
+
8
+ ### 🩹 Fixes
9
+ - Something went wrong when processing cache file with TTL - [#2](https://github.com/crenata/bejibun-cache/issues/2)
10
+
11
+ ### 📖 Changes
12
+
13
+ ### ❤️Contributors
14
+ - Havea Crenata ([@crenata](https://github.com/crenata))
15
+
16
+ **Full Changelog**: https://github.com/crenata/bejibun-cache/blob/master/CHANGELOG.md
17
+
18
+ ---
19
+
6
20
  ## [v0.1.15](https://github.com/crenata/bejibun-cache/compare/v0.1.14...v0.1.15) - 2025-12-14
7
21
 
8
22
  ### 🩹 Fixes
package/README.md CHANGED
@@ -71,6 +71,7 @@ How to use tha package.
71
71
  ```ts
72
72
  import Cache from "@bejibun/cache";
73
73
 
74
+ Cache.connection();
74
75
  await Cache.remember("key", () => {}, 60 /* seconds */); // any
75
76
  await Cache.has("key"); // boolean
76
77
  await Cache.get("key"); // any
@@ -87,19 +87,24 @@ export default class CacheBuilder {
87
87
  ttl: null,
88
88
  data: null
89
89
  };
90
- const file = this.file(key);
91
- if (await file.exists()) {
92
- const raw = await file.text();
93
- const [unix, ...rest] = raw.split("|");
94
- const ttl = Number(unix);
95
- const data = rest.join("|");
96
- if (isEmpty(ttl) || Luxon.DateTime.now().toUnixInteger() <= ttl)
97
- metadata = {
98
- ttl: defineValue(Number(ttl)),
99
- data
100
- };
101
- else
102
- await this.file(key).delete();
90
+ try {
91
+ const file = this.file(key);
92
+ if (await file.exists()) {
93
+ const raw = await file.text();
94
+ const [unix, ...rest] = raw.split("|");
95
+ const ttl = Number(unix);
96
+ const data = rest.join("|");
97
+ if (isEmpty(ttl) || Luxon.DateTime.now().toUnixInteger() <= ttl)
98
+ metadata = {
99
+ ttl: defineValue(Number(ttl)),
100
+ data
101
+ };
102
+ else
103
+ await file.delete();
104
+ }
105
+ }
106
+ catch (error) {
107
+ Logger.setContext("Cache").error("Something went wrong when processing cache file.").trace(error);
103
108
  }
104
109
  return metadata;
105
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bejibun/cache",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "author": "Havea Crenata <havea.crenata@gmail.com>",
5
5
  "repository": {
6
6
  "type": "git",