honojs-plugin-memory 0.0.0 → 0.0.1

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 +18 -18
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @honojs-plugins/memory
1
+ # honojs-plugin-memory
2
2
 
3
3
  Cache plugin for HonoJS. Supports two drivers:
4
4
 
@@ -10,7 +10,7 @@ Both drivers implement the same `CacheDriver` interface, so they are interchange
10
10
  ## Install
11
11
 
12
12
  ```bash
13
- pnpm add @honojs-plugins/memory
13
+ pnpm add honojs-plugin-memory
14
14
  ```
15
15
 
16
16
  ## Folder structure
@@ -33,13 +33,13 @@ src/
33
33
  ### 1. In-memory (LRU) cache
34
34
 
35
35
  ```ts
36
- import Cache, { MemoryCache } from '@honojs-plugins/memory'
36
+ import Cache, { MemoryCache } from 'honojs-plugin-memory'
37
37
 
38
38
  const cache = Cache.create({
39
39
  cacheType: 'memory',
40
40
  params: {
41
- max: 500, // max entries
42
- ttl: 60, // default TTL in seconds (optional)
41
+ max: 500, // max entries
42
+ ttl: 60, // default TTL in seconds (optional)
43
43
  },
44
44
  }) as MemoryCache
45
45
 
@@ -53,7 +53,7 @@ await cache.clear()
53
53
  ### 2. Redis cache
54
54
 
55
55
  ```ts
56
- import Cache, { RedisCache } from '@honojs-plugins/memory'
56
+ import Cache, { RedisCache } from 'honojs-plugin-memory'
57
57
 
58
58
  const cache = Cache.create({
59
59
  cacheType: 'redis',
@@ -79,7 +79,7 @@ cache.client.ping()
79
79
 
80
80
  ```ts
81
81
  import { Hono } from 'hono'
82
- import Cache, { RedisCache } from '@honojs-plugins/memory'
82
+ import Cache, { RedisCache } from 'honojs-plugin-memory'
83
83
 
84
84
  const app = new Hono()
85
85
 
@@ -112,17 +112,17 @@ async function fetchUserFromDb(id: string) {
112
112
 
113
113
  ### `Cache.create({ cacheType, params })`
114
114
 
115
- | `cacheType` | `params` shape |
116
- |---|---|
117
- | `'memory'` | `MemoryConfig` — `{ max?: number (default 500), ttl?: number }` |
118
- | `'redis'` | `RedisConfig` — `{ host?: string (default '127.0.0.1'), port?: number (default 6379), password?, db?, keyPrefix?, ttl? }` |
115
+ | `cacheType` | `params` shape |
116
+ | ----------- | ------------------------------------------------------------------------------------------------------------------------- |
117
+ | `'memory'` | `MemoryConfig` — `{ max?: number (default 500), ttl?: number }` |
118
+ | `'redis'` | `RedisConfig` — `{ host?: string (default '127.0.0.1'), port?: number (default 6379), password?, db?, keyPrefix?, ttl? }` |
119
119
 
120
120
  ### `CacheDriver` interface (implemented by both drivers)
121
121
 
122
- | Method | Description |
123
- |---|---|
124
- | `get<T>(key)` | Returns the cached value, or `undefined` if missing/expired |
125
- | `set<T>(key, value, ttl?)` | Stores `value`, optionally overriding the default TTL (seconds) |
126
- | `has(key)` | Returns `true` if `key` exists |
127
- | `del(key)` | Removes `key` from the cache |
128
- | `clear()` | Clears the entire cache (or Redis DB via `flushdb` for `RedisCache`) |
122
+ | Method | Description |
123
+ | -------------------------- | -------------------------------------------------------------------- |
124
+ | `get<T>(key)` | Returns the cached value, or `undefined` if missing/expired |
125
+ | `set<T>(key, value, ttl?)` | Stores `value`, optionally overriding the default TTL (seconds) |
126
+ | `has(key)` | Returns `true` if `key` exists |
127
+ | `del(key)` | Removes `key` from the cache |
128
+ | `clear()` | Clears the entire cache (or Redis DB via `flushdb` for `RedisCache`) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "honojs-plugin-memory",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "description": "Memory plugin for HonoJS",
5
5
  "type": "module",
6
6
  "sideEffects": false,