@bejibun/cache 0.1.1 → 0.1.11

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,21 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  ---
5
5
 
6
+ ## [v0.1.11](https://github.com/crenata/bejibun-cache/compare/v0.1.0...v0.1.11) - 2025-11-23
7
+
8
+ ### 🩹 Fixes
9
+
10
+ ### 📖 Changes
11
+ What's New :
12
+ - Adding `ttl` supports for increment & decrement
13
+
14
+ ### ❤️Contributors
15
+ - Havea Crenata ([@crenata](https://github.com/crenata))
16
+
17
+ **Full Changelog**: https://github.com/crenata/bejibun-cache/blob/master/CHANGELOG.md
18
+
19
+ ---
20
+
6
21
  ## [v0.1.1](https://github.com/crenata/bejibun-cache/compare/v0.1.0...v0.1.1) - 2025-11-23
7
22
 
8
23
  ### 🩹 Fixes
@@ -10,6 +10,6 @@ export default class CacheBuilder {
10
10
  add(key: string, value: any, ttl?: number): Promise<boolean>;
11
11
  put(key: string, value: any, ttl?: number): Promise<boolean>;
12
12
  forget(key: string): Promise<void>;
13
- increment(key: string): Promise<number>;
14
- decrement(key: string): Promise<number>;
13
+ increment(key: string, ttl?: number): Promise<number>;
14
+ decrement(key: string, ttl?: number): Promise<number>;
15
15
  }
@@ -124,18 +124,18 @@ export default class CacheBuilder {
124
124
  break;
125
125
  }
126
126
  }
127
- async increment(key) {
127
+ async increment(key, ttl) {
128
128
  let data;
129
129
  switch (this.config.connection) {
130
130
  case "redis":
131
131
  data = Number(await Redis.get(this.key(key)));
132
132
  if (isEmpty(data)) {
133
133
  data = 1;
134
- await Redis.set(this.key(key), data);
134
+ await Redis.set(this.key(key), data, ttl);
135
135
  }
136
136
  else {
137
137
  data++;
138
- await Redis.set(this.key(key), data);
138
+ await Redis.set(this.key(key), data, ttl);
139
139
  }
140
140
  break;
141
141
  default:
@@ -144,18 +144,18 @@ export default class CacheBuilder {
144
144
  }
145
145
  return data;
146
146
  }
147
- async decrement(key) {
147
+ async decrement(key, ttl) {
148
148
  let data;
149
149
  switch (this.config.connection) {
150
150
  case "redis":
151
151
  data = Number(await Redis.get(this.key(key)));
152
152
  if (isEmpty(data)) {
153
153
  data = -1;
154
- await Redis.set(this.key(key), data);
154
+ await Redis.set(this.key(key), data, ttl);
155
155
  }
156
156
  else {
157
157
  data--;
158
- await Redis.set(this.key(key), data);
158
+ await Redis.set(this.key(key), data, ttl);
159
159
  }
160
160
  break;
161
161
  default:
@@ -2,9 +2,9 @@ export default class Cache {
2
2
  static remember(key: string, callback: Function, ttl?: number): Promise<any>;
3
3
  static has(key: string): Promise<boolean>;
4
4
  static get(key: string): Promise<any>;
5
- static add(key: string, value: string, ttl?: number): Promise<boolean>;
6
- static put(key: string, value: string, ttl?: number): Promise<boolean>;
5
+ static add(key: string, value: any, ttl?: number): Promise<boolean>;
6
+ static put(key: string, value: any, ttl?: number): Promise<boolean>;
7
7
  static forget(key: string): Promise<void>;
8
- static increment(key: string): Promise<number>;
9
- static decrement(key: string): Promise<number>;
8
+ static increment(key: string, ttl?: number): Promise<number>;
9
+ static decrement(key: string, ttl?: number): Promise<number>;
10
10
  }
package/facades/Cache.js CHANGED
@@ -18,10 +18,10 @@ export default class Cache {
18
18
  static async forget(key) {
19
19
  return new CacheBuilder().forget(key);
20
20
  }
21
- static async increment(key) {
22
- return new CacheBuilder().increment(key);
21
+ static async increment(key, ttl) {
22
+ return new CacheBuilder().increment(key, ttl);
23
23
  }
24
- static async decrement(key) {
25
- return new CacheBuilder().decrement(key);
24
+ static async decrement(key, ttl) {
25
+ return new CacheBuilder().decrement(key, ttl);
26
26
  }
27
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bejibun/cache",
3
- "version": "0.1.1",
3
+ "version": "0.1.11",
4
4
  "author": "Havea Crenata <havea.crenata@gmail.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "@bejibun/app": "^0.1.22",
39
39
  "@bejibun/logger": "^0.1.22",
40
- "@bejibun/redis": "^0.1.33",
41
- "@bejibun/utils": "^0.1.20"
40
+ "@bejibun/redis": "^0.1.34",
41
+ "@bejibun/utils": "^0.1.21"
42
42
  }
43
43
  }