@miniflare/storage-redis
Advanced tools
Comparing version 2.0.0-rc.3 to 2.0.0-rc.4
@@ -0,13 +1,37 @@ | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); | ||
var __export = (target, all) => { | ||
__markAsModule(target); | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __reExport = (target, module2, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && key !== "default") | ||
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
}; | ||
var __toModule = (module2) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2); | ||
}; | ||
// packages/storage-redis/src/index.ts | ||
import assert from "assert"; | ||
import { | ||
Storage, | ||
millisToSeconds, | ||
viewToArray | ||
} from "@miniflare/shared"; | ||
import { listFilterMatch, listPaginate } from "@miniflare/storage-memory"; | ||
__export(exports, { | ||
RedisStorage: () => RedisStorage, | ||
_bufferFromArray: () => _bufferFromArray | ||
}); | ||
var import_assert = __toModule(require("assert")); | ||
var import_shared = __toModule(require("@miniflare/shared")); | ||
var import_storage_memory = __toModule(require("@miniflare/storage-memory")); | ||
function _bufferFromArray(value) { | ||
return Buffer.from(value.buffer, value.byteOffset, value.byteLength); | ||
} | ||
var RedisStorage = class extends Storage { | ||
var RedisStorage = class extends import_shared.Storage { | ||
constructor(redis, namespace) { | ||
@@ -37,6 +61,6 @@ super(); | ||
const value2 = await this.#redis.getBuffer(this.#key(key)); | ||
return value2 === null ? void 0 : { value: viewToArray(value2) }; | ||
return value2 === null ? void 0 : { value: (0, import_shared.viewToArray)(value2) }; | ||
} | ||
const pipelineRes = await this.#redis.pipeline().getBuffer(this.#key(key)).get(this.#metaKey(key)).pttl(this.#key(key)).exec(); | ||
assert.strictEqual(pipelineRes.length, 3); | ||
import_assert.default.strictEqual(pipelineRes.length, 3); | ||
this.throwPipelineErrors(pipelineRes); | ||
@@ -49,5 +73,5 @@ const value = pipelineRes[0][1]; | ||
return { | ||
value: viewToArray(value), | ||
value: (0, import_shared.viewToArray)(value), | ||
metadata: meta ? JSON.parse(meta) : void 0, | ||
expiration: ttl >= 0 ? millisToSeconds(Date.now() + ttl) : void 0 | ||
expiration: ttl >= 0 ? (0, import_shared.millisToSeconds)(Date.now() + ttl) : void 0 | ||
}; | ||
@@ -60,3 +84,3 @@ } | ||
const values2 = await this.#redis.mgetBuffer(...keys.map(this.#key)); | ||
return values2.map((value) => value === null ? void 0 : { value: viewToArray(value) }); | ||
return values2.map((value) => value === null ? void 0 : { value: (0, import_shared.viewToArray)(value) }); | ||
} | ||
@@ -69,8 +93,8 @@ const redisKeys = keys.map(this.#key); | ||
const pipelineRes = await pipeline.exec(); | ||
assert.strictEqual(pipelineRes.length, 2 + keys.length); | ||
import_assert.default.strictEqual(pipelineRes.length, 2 + keys.length); | ||
this.throwPipelineErrors(pipelineRes); | ||
const values = pipelineRes[0][1]; | ||
const metas = pipelineRes[1][1]; | ||
assert.strictEqual(values.length, keys.length); | ||
assert.strictEqual(metas.length, keys.length); | ||
import_assert.default.strictEqual(values.length, keys.length); | ||
import_assert.default.strictEqual(metas.length, keys.length); | ||
const now = Date.now(); | ||
@@ -86,5 +110,5 @@ const res = new Array(keys.length); | ||
res[i] = { | ||
value: viewToArray(value), | ||
value: (0, import_shared.viewToArray)(value), | ||
metadata: meta ? JSON.parse(meta) : void 0, | ||
expiration: ttl >= 0 ? millisToSeconds(now + ttl) : void 0 | ||
expiration: ttl >= 0 ? (0, import_shared.millisToSeconds)(now + ttl) : void 0 | ||
}; | ||
@@ -132,3 +156,3 @@ } | ||
const pipelineRes = await pipeline.exec(); | ||
assert.strictEqual(pipelineRes.length, 2); | ||
import_assert.default.strictEqual(pipelineRes.length, 2); | ||
this.throwPipelineErrors(pipelineRes); | ||
@@ -147,3 +171,3 @@ return pipelineRes[0][1]; | ||
const name = key.substring(redisKeyPrefix.length); | ||
if (listFilterMatch(options, name)) | ||
if ((0, import_storage_memory.listFilterMatch)(options, name)) | ||
keys2.push({ name }); | ||
@@ -154,3 +178,3 @@ } | ||
}); | ||
const res = listPaginate(options, keys); | ||
const res = (0, import_storage_memory.listPaginate)(options, keys); | ||
if (skipMetadata || res.keys.length === 0) | ||
@@ -163,6 +187,6 @@ return res; | ||
const pipelineRes = await pipeline.exec(); | ||
assert.strictEqual(pipelineRes.length, 1 + res.keys.length); | ||
import_assert.default.strictEqual(pipelineRes.length, 1 + res.keys.length); | ||
this.throwPipelineErrors(pipelineRes); | ||
const metas = pipelineRes[0][1]; | ||
assert.strictEqual(metas.length, res.keys.length); | ||
import_assert.default.strictEqual(metas.length, res.keys.length); | ||
const now = Date.now(); | ||
@@ -173,3 +197,3 @@ for (let i = 0; i < res.keys.length; i++) { | ||
res.keys[i].metadata = meta ? JSON.parse(meta) : void 0; | ||
res.keys[i].expiration = ttl >= 0 ? millisToSeconds(now + ttl) : void 0; | ||
res.keys[i].expiration = ttl >= 0 ? (0, import_shared.millisToSeconds)(now + ttl) : void 0; | ||
} | ||
@@ -179,6 +203,7 @@ return res; | ||
}; | ||
export { | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
RedisStorage, | ||
_bufferFromArray | ||
}; | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@miniflare/storage-redis", | ||
"version": "2.0.0-rc.3", | ||
"version": "2.0.0-rc.4", | ||
"description": "Redis storage module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers", | ||
@@ -14,4 +14,3 @@ "keywords": [ | ||
"license": "MIT", | ||
"type": "module", | ||
"exports": "./dist/src/index.js", | ||
"main": "./dist/src/index.js", | ||
"types": "./dist/src/index.d.ts", | ||
@@ -40,10 +39,10 @@ "files": [ | ||
"dependencies": { | ||
"@miniflare/shared": "2.0.0-rc.3", | ||
"@miniflare/storage-memory": "2.0.0-rc.3", | ||
"@miniflare/shared": "2.0.0-rc.4", | ||
"@miniflare/storage-memory": "2.0.0-rc.4", | ||
"ioredis": "^4.27.9" | ||
}, | ||
"devDependencies": { | ||
"@miniflare/shared-test": "2.0.0-rc.3", | ||
"@miniflare/shared-test": "2.0.0-rc.4", | ||
"@types/ioredis": "^4.27.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15009
226
No
+ Added@miniflare/shared@2.0.0-rc.4(transitive)
+ Added@miniflare/storage-memory@2.0.0-rc.4(transitive)
- Removed@miniflare/shared@2.0.0-rc.3(transitive)
- Removed@miniflare/storage-memory@2.0.0-rc.3(transitive)
Updated@miniflare/shared@2.0.0-rc.4