flamecache 0.0.1 → 0.0.2
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/README.md +14 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/flamecache)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](https://bundlephobia.com/package/flamecache)
|
|
6
7
|
[](https://github.com/iamanishroy/flamecache/actions)
|
|
7
8
|
|
|
8
9
|
> A Redis-like caching layer for Firebase Realtime Database with automatic expiration, counters, and batch operations.
|
|
@@ -12,7 +13,7 @@ Flamecache is a lightweight, robust caching solution that brings Redis-style ope
|
|
|
12
13
|
## ✨ Features
|
|
13
14
|
|
|
14
15
|
- 🚀 **Redis-like API** - Familiar `get`, `set`, `incr`, `decr`, `expire` operations
|
|
15
|
-
- ⚡ **Fast & Lightweight** - Only
|
|
16
|
+
- ⚡ **Fast & Lightweight** - Only ~1KB (minified), no heavy dependencies
|
|
16
17
|
- 🔄 **Auto-expiration** - Built-in TTL support with automatic cleanup
|
|
17
18
|
- 📊 **Counters** - Atomic increment/decrement operations
|
|
18
19
|
- 📦 **Batch Operations** - Multi-get, multi-set, multi-delete
|
|
@@ -126,6 +127,14 @@ Clear all cache entries.
|
|
|
126
127
|
await cache.clear();
|
|
127
128
|
```
|
|
128
129
|
|
|
130
|
+
#### `disconnect(): Promise<void>`
|
|
131
|
+
|
|
132
|
+
Close the connection to Firebase. Crucial for Node.js scripts to exit cleanly.
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
await cache.disconnect();
|
|
136
|
+
```
|
|
137
|
+
|
|
129
138
|
### Counter Operations
|
|
130
139
|
|
|
131
140
|
#### `incr(key: string, by?: number): Promise<number>`
|
|
@@ -166,7 +175,7 @@ Get remaining time-to-live in seconds.
|
|
|
166
175
|
- Returns remaining seconds otherwise
|
|
167
176
|
|
|
168
177
|
```typescript
|
|
169
|
-
const remaining = await cache.
|
|
178
|
+
const remaining = await cache.getTtl('session:abc');
|
|
170
179
|
if (remaining > 0 && remaining < 300) {
|
|
171
180
|
console.log('Session expiring soon!');
|
|
172
181
|
}
|
|
@@ -483,7 +492,7 @@ const response = await cache.wrap<ApiResponse>('api:users', fetchUsers);
|
|
|
483
492
|
```json
|
|
484
493
|
{
|
|
485
494
|
"rules": {
|
|
486
|
-
"
|
|
495
|
+
"flamecache": {
|
|
487
496
|
".read": true,
|
|
488
497
|
".write": true
|
|
489
498
|
}
|
|
@@ -496,7 +505,7 @@ const response = await cache.wrap<ApiResponse>('api:users', fetchUsers);
|
|
|
496
505
|
```json
|
|
497
506
|
{
|
|
498
507
|
"rules": {
|
|
499
|
-
"
|
|
508
|
+
"flamecache": {
|
|
500
509
|
".read": "auth != null",
|
|
501
510
|
".write": "auth != null"
|
|
502
511
|
}
|
|
@@ -509,7 +518,7 @@ const response = await cache.wrap<ApiResponse>('api:users', fetchUsers);
|
|
|
509
518
|
```json
|
|
510
519
|
{
|
|
511
520
|
"rules": {
|
|
512
|
-
"
|
|
521
|
+
"flamecache": {
|
|
513
522
|
"users": {
|
|
514
523
|
"$uid": {
|
|
515
524
|
".read": "$uid === auth.uid",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flamecache",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Simple and robust caching layer using Firebase Realtime Database",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"firebase",
|
|
34
34
|
"cache",
|
|
35
35
|
"caching",
|
|
36
|
-
"redis
|
|
36
|
+
"redis",
|
|
37
37
|
"realtime-database"
|
|
38
38
|
],
|
|
39
39
|
"author": "Anish Roy",
|