@h-ai/cache 1.0.0-beta.18 → 1.0.0-beta.19

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.en.md CHANGED
@@ -10,6 +10,8 @@ A unified cache module. The `cache` object provides KV / Hash / List / Set / ZSe
10
10
 
11
11
  Memory KV entries expire at their expiration time. `incr/decr/incrBy/decrBy` accept only safe integers or integer strings; invalid increments and overflow return `OPERATION_FAILED` without changing the original value. Hash names such as `__proto__` / `constructor` remain ordinary fields and do not change the returned object's prototype.
12
12
 
13
+ Memory KV, Hash, List, Set, and ZSet share one key namespace. `exists/expire/expireAt/ttl/persist/keys/scan/del/type` cover every structure; structure operations also treat expired keys as absent. del counts logical keys actually removed, and structure operations on another key type fail.
14
+
13
15
  Connections become available only after a successful health check. Failed initialization disposes its candidate; `error.ext.cleanupPending === true` identifies cleanup that still needs retry. `cache.close()` returns `Promise<HaiResult<void>>`, waits for initialization, and coalesces concurrent close calls. Once cleanup starts, `isInitialized` is false and configuration/operations are unavailable. A failed cleanup retains the resource: the next `close()` or `init()` retries disposal before allocating a replacement. Always inspect the close result.
14
16
 
15
17
  ```ts
@@ -95,7 +97,9 @@ await cache.init({
95
97
  await cache.init({
96
98
  type: 'redis',
97
99
  sentinel: {
98
- sentinels: [{ host: 'sentinel1', port: 26379 }],
100
+ sentinels: [
101
+ { host: 'sentinel1', port: 26379 }
102
+ ],
99
103
  name: 'mymaster',
100
104
  },
101
105
  })
package/README.ja.md CHANGED
@@ -10,6 +10,8 @@
10
10
 
11
11
  メモリー KV は有効期限に達した時点で無効になります。`incr/decr/incrBy/decrBy` は安全な整数値または整数文字列のみを受け付け、不正な増分やオーバーフローでは元の値を保持して `OPERATION_FAILED` を返します。Hash の `__proto__` / `constructor` などは通常のフィールドとして保持され、戻り値のオブジェクトのプロトタイプを変更しません。
12
12
 
13
+ Memory の KV・Hash・List・Set・ZSet は一つの key 名前空間を共有します。`exists/expire/expireAt/ttl/persist/keys/scan/del/type` は全構造を対象とし、期限切れ key は構造操作でも直ちに存在しないものとして扱います。del は実際に削除した論理 key を数え、異なる型の構造操作は失敗します。
14
+
13
15
  接続はヘルスチェック成功後に公開します。初期化失敗時は候補リソースを解放し、解放にも失敗した場合は初期化エラーの `error.ext.cleanupPending` が `true` になります。`cache.close()` は `Promise<HaiResult<void>>` を返し、初期化を待機して並行する終了処理をまとめます。解放開始後は `isInitialized` が `false` となり、設定と操作は利用できません。解放に失敗したリソースは保持され、次の `close()` または `init()` で再試行します。解放が成功するまで代替接続は作成しません。終了結果を必ず確認してください。
14
16
 
15
17
  ```ts
@@ -95,7 +97,9 @@ await cache.init({
95
97
  await cache.init({
96
98
  type: 'redis',
97
99
  sentinel: {
98
- sentinels: [{ host: 'sentinel1', port: 26379 }],
100
+ sentinels: [
101
+ { host: 'sentinel1', port: 26379 }
102
+ ],
99
103
  name: 'mymaster',
100
104
  },
101
105
  })
package/README.md CHANGED
@@ -10,6 +10,8 @@
10
10
 
11
11
  内存 KV 在到期时间点即视为失效;`incr/decr/incrBy/decrBy` 只接受安全整数数值或整数字符串,非法增量和溢出返回 `OPERATION_FAILED` 并保留原值。Hash 的 `__proto__` / `constructor` 等名称按普通字段保留,不修改返回对象原型。
12
12
 
13
+ Memory 的 KV、Hash、List、Set、ZSet 共用 key 命名空间。`exists/expire/expireAt/ttl/persist/keys/scan/del/type` 覆盖全部结构,期限到达后结构操作也立即视为不存在;del 按实际删除的逻辑 key 计数,错误类型的结构操作返回失败。
14
+
13
15
  初始化只在健康检查成功后发布连接;失败时释放候选资源。若清理仍失败,初始化错误的 `error.ext.cleanupPending` 为 `true`。`cache.close()` 返回 `Promise<HaiResult<void>>`,等待正在进行的初始化,并合并并发关闭。开始清理后 `isInitialized` 为 `false`,配置与业务操作不再可用;清理失败仍保留资源,后续 `close()` 或 `init()` 先重试释放,成功前不会创建替代连接。调用方必须检查关闭结果。
14
16
 
15
17
  ```ts
@@ -95,7 +97,9 @@ await cache.init({
95
97
  await cache.init({
96
98
  type: 'redis',
97
99
  sentinel: {
98
- sentinels: [{ host: 'sentinel1', port: 26379 }],
100
+ sentinels: [
101
+ { host: 'sentinel1', port: 26379 }
102
+ ],
99
103
  name: 'mymaster',
100
104
  },
101
105
  })
package/dist/index.d.ts CHANGED
@@ -668,4 +668,5 @@ interface CacheFunctions extends CacheCompositeOperations {
668
668
  */
669
669
  declare const cache: CacheFunctions;
670
670
 
671
- export { type CacheCompositeOperations, type CacheConfig, type CacheConfigInput, CacheConfigSchema, type CacheFunctions, type CacheValue, type CompareAndSwapOptions, HaiCacheError, type HashOperations, type KvOperations, type ListOperations, type LockOperations, type LockOptions, MemoryConfigSchema, type RedisClusterNode, RedisClusterNodeSchema, RedisConfigSchema, type RedisSentinelConfig, RedisSentinelConfigSchema, type ScanOptions, type SetOperations, type SetOptions, type ZMember, type ZSetOperations, cache };
671
+ export { CacheConfigSchema, HaiCacheError, MemoryConfigSchema, RedisClusterNodeSchema, RedisConfigSchema, RedisSentinelConfigSchema, cache };
672
+ export type { CacheCompositeOperations, CacheConfig, CacheConfigInput, CacheFunctions, CacheValue, CompareAndSwapOptions, HashOperations, KvOperations, ListOperations, LockOperations, LockOptions, RedisClusterNode, RedisSentinelConfig, ScanOptions, SetOperations, SetOptions, ZMember, ZSetOperations };