@devbro/neko-cache 0.1.8 → 0.1.9

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.
Files changed (2) hide show
  1. package/README.md +84 -21
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,31 +1,94 @@
1
- # @devbro/neko-scheduler
1
+ # @devbro/neko-cache
2
2
 
3
- customizable cron/scheduling solution with support for context.
3
+ A flexible and customizable caching solution for Node.js and bun applications with support for multiple providers.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @devbro/neko-cache
9
+ ```
10
+
11
+ ## Features
12
+
13
+ - Multiple cache providers (Redis, Memory, etc.)
14
+ - Simple and intuitive API
15
+ - TypeScript support
16
+ - Async/await support
17
+ - TTL (Time To Live) support
18
+ - Key prefixing and namespacing
19
+
20
+ ## Usage
21
+
22
+ ### Basic Example
4
23
 
5
24
  ```ts
6
- import { Scheduler } from '@devbro/neko-scheduler';
25
+ import { CacheManager } from '@devbro/neko-cache';
7
26
 
8
- const scheduler = new Scheduler();
27
+ // Create a cache instance
28
+ const cache = new CacheManager();
9
29
 
10
- //if you want to add a wrapper around all your schedules.
11
- scheduler.setContextWrapper(async (tickFunction: Function) => {
12
- // ???
13
- await tickFunction();
14
- // ???
15
- });
30
+ // Set a value
31
+ await cache.set('key', 'value', 3600); // TTL in seconds
32
+
33
+ // Get a value
34
+ const value = await cache.get('key');
35
+
36
+ // Delete a value
37
+ await cache.delete('key');
38
+
39
+ // Clear all cache
40
+ await cache.clear();
41
+ ```
42
+
43
+ ### Advanced Usage
16
44
 
17
- scheduler.setErrorHandler((err: any) => {
18
- console.log('scheduler error', err);
45
+ ```ts
46
+ import { CacheManager, MemoryProvider } from '@devbro/neko-cache';
47
+
48
+ // Create cache with custom provider
49
+ const cache = new CacheManager({
50
+ provider: new MemoryProvider(),
51
+ prefix: 'myapp:',
19
52
  });
20
53
 
21
- scheduler
22
- .call(() => {
23
- console.log('Hello World');
24
- })
25
- .setName('test1')
26
- .setCronTime('*/5 * * * *')
27
- .setTimezone('UTC');
54
+ // Check if key exists
55
+ const exists = await cache.has('key');
56
+
57
+ // Get multiple values
58
+ const values = await cache.getMany(['key1', 'key2', 'key3']);
28
59
 
29
- scheduler.start();
30
- scheduler.stop();
60
+ // Set multiple values
61
+ await cache.setMany(
62
+ {
63
+ key1: 'value1',
64
+ key2: 'value2',
65
+ },
66
+ 3600
67
+ );
68
+
69
+ // Delete multiple keys
70
+ await cache.deleteMany(['key1', 'key2']);
31
71
  ```
72
+
73
+ ## API Reference
74
+
75
+ ### `CacheManager`
76
+
77
+ #### Methods
78
+
79
+ - `get(key: string): Promise<any>` - Retrieve a value from cache
80
+ - `set(key: string, value: any, ttl?: number): Promise<void>` - Store a value in cache
81
+ - `has(key: string): Promise<boolean>` - Check if a key exists
82
+ - `delete(key: string): Promise<void>` - Remove a value from cache
83
+ - `clear(): Promise<void>` - Clear all cached values
84
+ - `getMany(keys: string[]): Promise<any[]>` - Retrieve multiple values
85
+ - `setMany(items: Record<string, any>, ttl?: number): Promise<void>` - Store multiple values
86
+ - `deleteMany(keys: string[]): Promise<void>` - Remove multiple values
87
+
88
+ ## License
89
+
90
+ MIT
91
+
92
+ ## Contributing
93
+
94
+ Contributions are welcome! Please feel free to submit a Pull Request.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devbro/neko-cache",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "driver agnostic caching implementation",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",