@abtnode/db-cache 1.16.54-beta-20251023-041534-36eec6b9 → 1.16.54-beta-20251027-105624-dfa978f8

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/dist/index.cjs CHANGED
@@ -200,7 +200,7 @@ var __publicField$3 = (obj, key, value) => {
200
200
  return value;
201
201
  };
202
202
  const retryOptions = {
203
- needRetry: (err) => err.message?.includes("SQLITE_BUSY")
203
+ needRetry: (err) => err.message?.includes("SQLITE_BUSY") || err.message?.includes("disk I/O")
204
204
  };
205
205
  const dbRun = (db, sql, params) => {
206
206
  return withRetry(() => {
@@ -261,7 +261,7 @@ const _SqliteAdapter = class _SqliteAdapter {
261
261
  }
262
262
  async ensure() {
263
263
  if (!this.dbPath) {
264
- this.dbPath = path__namespace.resolve(this.opts.sqlitePath);
264
+ this.dbPath = this.opts.sqlitePath === ":memory:" ? ":memory:" : path__namespace.resolve(this.opts.sqlitePath);
265
265
  this.prefix = this.opts.prefix;
266
266
  this.defaultTtl = this.opts.ttl;
267
267
  this.cleanupInterval = this.opts.cleanupInterval ?? 30 * 60 * 1e3;
@@ -826,13 +826,13 @@ class LockDBCache extends SingleFlightDBCache {
826
826
  }
827
827
 
828
828
  const isJestTest = () => {
829
- return process.env.NODE_ENV === "test" || process.env.BABEL_ENV === "test" || typeof jest !== "undefined";
829
+ return process.env.NODE_ENV === "test" || process.env.BABEL_ENV === "test";
830
830
  };
831
831
  const getAbtNodeRedisAndSQLiteUrl = () => {
832
832
  const blockletCacheDir = process.env.BLOCKLET_DATA_DIR ? path__default.join(process.env.BLOCKLET_DATA_DIR, "__default-cache-store.db") : void 0;
833
833
  const params = {
834
834
  redisUrl: process.env.ABT_NODE_CACHE_REDIS_URL,
835
- sqlitePath: isJestTest() ? "test.db" : blockletCacheDir || process.env.ABT_NODE_CACHE_SQLITE_PATH
835
+ sqlitePath: isJestTest() ? ":memory:" : blockletCacheDir || process.env.ABT_NODE_CACHE_SQLITE_PATH
836
836
  };
837
837
  if (process.env.ABT_NODE_NO_CACHE === "true") {
838
838
  params.ttl = 1;
package/dist/index.mjs CHANGED
@@ -180,7 +180,7 @@ var __publicField$3 = (obj, key, value) => {
180
180
  return value;
181
181
  };
182
182
  const retryOptions = {
183
- needRetry: (err) => err.message?.includes("SQLITE_BUSY")
183
+ needRetry: (err) => err.message?.includes("SQLITE_BUSY") || err.message?.includes("disk I/O")
184
184
  };
185
185
  const dbRun = (db, sql, params) => {
186
186
  return withRetry(() => {
@@ -241,7 +241,7 @@ const _SqliteAdapter = class _SqliteAdapter {
241
241
  }
242
242
  async ensure() {
243
243
  if (!this.dbPath) {
244
- this.dbPath = path.resolve(this.opts.sqlitePath);
244
+ this.dbPath = this.opts.sqlitePath === ":memory:" ? ":memory:" : path.resolve(this.opts.sqlitePath);
245
245
  this.prefix = this.opts.prefix;
246
246
  this.defaultTtl = this.opts.ttl;
247
247
  this.cleanupInterval = this.opts.cleanupInterval ?? 30 * 60 * 1e3;
@@ -806,13 +806,13 @@ class LockDBCache extends SingleFlightDBCache {
806
806
  }
807
807
 
808
808
  const isJestTest = () => {
809
- return process.env.NODE_ENV === "test" || process.env.BABEL_ENV === "test" || typeof jest !== "undefined";
809
+ return process.env.NODE_ENV === "test" || process.env.BABEL_ENV === "test";
810
810
  };
811
811
  const getAbtNodeRedisAndSQLiteUrl = () => {
812
812
  const blockletCacheDir = process.env.BLOCKLET_DATA_DIR ? path__default.join(process.env.BLOCKLET_DATA_DIR, "__default-cache-store.db") : void 0;
813
813
  const params = {
814
814
  redisUrl: process.env.ABT_NODE_CACHE_REDIS_URL,
815
- sqlitePath: isJestTest() ? "test.db" : blockletCacheDir || process.env.ABT_NODE_CACHE_SQLITE_PATH
815
+ sqlitePath: isJestTest() ? ":memory:" : blockletCacheDir || process.env.ABT_NODE_CACHE_SQLITE_PATH
816
816
  };
817
817
  if (process.env.ABT_NODE_NO_CACHE === "true") {
818
818
  params.ttl = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/db-cache",
3
- "version": "1.16.54-beta-20251023-041534-36eec6b9",
3
+ "version": "1.16.54-beta-20251027-105624-dfa978f8",
4
4
  "description": "Db cache use redis or sqlite as backend",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -20,8 +20,8 @@
20
20
  "ts-check": "npx tsc --noemit --skipLibCheck --incremental --tsBuildInfoFile './node_modules/.tsbuildinfo'",
21
21
  "lint": "npm run ts-check && eslint src",
22
22
  "lint:fix": "npm run lint -- --fix",
23
- "test": "bun test",
24
- "coverage": "bun test --coverage",
23
+ "test": "bun test --bail --timeout 30000",
24
+ "coverage": "bun test --bail --timeout 30000 --coverage",
25
25
  "build": "unbuild",
26
26
  "build:db-cache": "unbuild && npm run build"
27
27
  },
@@ -34,16 +34,13 @@
34
34
  },
35
35
  "devDependencies": {
36
36
  "@arcblock/eslint-config-ts": "^0.3.3",
37
- "@types/jest": "^29.5.13",
38
37
  "@types/node": "^22.7.5",
39
38
  "@typescript-eslint/eslint-plugin": "^5.42.0",
40
39
  "@typescript-eslint/parser": "^5.42.0",
41
40
  "eslint": "^8.57.0",
42
- "jest": "^29.7.0",
43
41
  "prettier": "^3.3.2",
44
- "ts-jest": "^29.2.5",
45
42
  "typescript": "^5.6.3",
46
43
  "unbuild": "^2.0.0"
47
44
  },
48
- "gitHead": "a642bc21c7c0f4aaccae2758d6b1d836d078bc1b"
45
+ "gitHead": "03b0bb26807c6c427ca700f48566ecc913f1353e"
49
46
  }