UNPKG

ram64

Version:

Multi-threaded 64bit memory cache database inspired by redis-like features

23 lines (22 loc) 735 B
"use strict"; exports.fn = void 0; var _shards = require("../shards"); var _promises = require("fs/promises"); const fn = async (opts)=>{ const { dirPath } = opts.args; for (let shard of _shards.Shards){ const filePath = `${dirPath}/shard${shard.shardIndex}.json`; const json = await (0, _promises).readFile(filePath, 'utf8'); const arr = JSON.parse(json, reviver); for (let [key, value] of arr){ shard.map.set(key, value); } } }; exports.fn = fn; function reviver(key, value) { if (Array.isArray(value?.$map)) return new Map(value.$map); else if (Array.isArray(value?.$set)) return new Set(value.$set); else return value; } //# sourceMappingURL=load.js.map