UNPKG

n8n-nodes-wax

Version:

n8n Community Node Package for the WAX Blockchain

58 lines (57 loc) 2.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const BaseCache_1 = require("./BaseCache"); class RpcCache { constructor() { this.cache = new BaseCache_1.MemoryCache(); } getAsset(assetID, data) { if (data) { data.mutable_serialized_data = new Uint8Array(data.mutable_serialized_data); data.immutable_serialized_data = new Uint8Array(data.immutable_serialized_data); } return this.access('assets', assetID, data); } deleteAsset(assetID) { this.delete('assets', assetID); } getTemplate(collectionName, templateID, data) { if (data) { data.immutable_serialized_data = new Uint8Array(data.immutable_serialized_data); } return this.access('templates', collectionName + ':' + templateID, data); } deleteTemplate(collectionName, templateID) { this.delete('templates', collectionName + ':' + templateID); } getSchema(collectionName, schemaName, data) { return this.access('schemas', collectionName + ':' + schemaName, data); } deleteSchema(collectionName, schemaName) { this.delete('schemas', collectionName + ':' + schemaName); } getCollection(collectionName, data) { return this.access('collections', collectionName, data); } deleteCollection(collectionName) { this.delete('collections', collectionName); } getOffer(offerID, data) { return this.access('offers', offerID, data); } deleteOffer(offerID) { this.delete('offers', offerID); } access(namespace, identifier, data) { if (typeof data === 'undefined') { const cache = this.cache.get(namespace + ':' + identifier); return cache === null ? null : cache; } this.cache.put(namespace + ':' + identifier, data, 15 * 60 * 1000); return data; } delete(namespace, identifier) { this.cache.remove(namespace + ':' + identifier); } } exports.default = RpcCache;