Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ivfuture/ecomm-cache-inmemory

Package Overview
Dependencies
Maintainers
0
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ivfuture/ecomm-cache-inmemory - npm Package Compare versions

Comparing version 1.58.0 to 1.58.1

15

dist/services/inmemory-cache.d.ts
/// <reference types="node" />
import { ICacheService } from "@ivfuture/ecomm-types";
import { AbstractCacheService } from "@ivfuture/ecomm-core";
import { Logger, MedusaContainer } from "@ivfuture/ecomm-types";
import { CacheRecord, InMemoryCacheModuleOptions } from "../types";
type InjectedDependencies = {};
/**
* Class represents basic, in-memory, cache store.
* Class represents a basic, in-memory cache store.
*/
declare class InMemoryCacheService implements ICacheService {
declare class InMemoryCacheService extends AbstractCacheService {
protected readonly store: Map<string, CacheRecord<any>>;
protected readonly timeoutRefs: Map<string, NodeJS.Timeout>;
protected readonly logger_: Logger;
protected readonly TTL: number;
protected readonly store: Map<string, CacheRecord<any>>;
protected readonly timoutRefs: Map<string, NodeJS.Timeout>;
constructor(deps: InjectedDependencies, options?: InMemoryCacheModuleOptions);
constructor(container: MedusaContainer, options?: InMemoryCacheModuleOptions);
/**

@@ -14,0 +15,0 @@ * Retrieve data from the cache.

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -39,13 +54,17 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

Object.defineProperty(exports, "__esModule", { value: true });
var DEFAULT_TTL = 30; // seconds
var ecomm_core_1 = require("@ivfuture/ecomm-core");
var DEFAULT_CACHE_TIME = 30;
/**
* Class represents basic, in-memory, cache store.
* Class represents a basic, in-memory cache store.
*/
var InMemoryCacheService = /** @class */ (function () {
function InMemoryCacheService(deps, options) {
var InMemoryCacheService = /** @class */ (function (_super) {
__extends(InMemoryCacheService, _super);
function InMemoryCacheService(container, options) {
if (options === void 0) { options = {}; }
var _a;
this.store = new Map();
this.timoutRefs = new Map();
this.TTL = (_a = options.ttl) !== null && _a !== void 0 ? _a : DEFAULT_TTL;
var _this = _super.call(this, container) || this;
_this.store = new Map();
_this.timeoutRefs = new Map();
_this.TTL = (_a = options.ttl) !== null && _a !== void 0 ? _a : DEFAULT_CACHE_TIME;
return _this;
}

@@ -86,10 +105,10 @@ /**

if (oldRecord) {
clearTimeout(this.timoutRefs.get(key));
this.timoutRefs.delete(key);
clearTimeout(this.timeoutRefs.get(key));
this.timeoutRefs.delete(key);
}
ref = setTimeout(function () {
_this.invalidate(key);
void _this.invalidate(key);
}, ttl * 1000);
ref.unref();
this.timoutRefs.set(key, ref);
this.timeoutRefs.set(key, ref);
this.store.set(key, record);

@@ -117,6 +136,6 @@ return [2 /*return*/];

keys.forEach(function (key) {
var timeoutRef = _this.timoutRefs.get(key);
var timeoutRef = _this.timeoutRefs.get(key);
if (timeoutRef) {
clearTimeout(timeoutRef);
_this.timoutRefs.delete(key);
_this.timeoutRefs.delete(key);
}

@@ -135,4 +154,4 @@ _this.store.delete(key);

return __generator(this, function (_a) {
this.timoutRefs.forEach(function (ref) { return clearTimeout(ref); });
this.timoutRefs.clear();
this.timeoutRefs.forEach(function (ref) { return clearTimeout(ref); });
this.timeoutRefs.clear();
this.store.clear();

@@ -144,4 +163,4 @@ return [2 /*return*/];

return InMemoryCacheService;
}());
}(ecomm_core_1.AbstractCacheService));
exports.default = InMemoryCacheService;
//# sourceMappingURL=inmemory-cache.js.map
{
"name": "@ivfuture/ecomm-cache-inmemory",
"version": "1.58.0",
"version": "1.58.1",
"description": "In-memory Cache Module for Medusa",

@@ -20,3 +20,3 @@ "main": "dist/index.js",

"devDependencies": {
"@ivfuture/ecomm-types": "1.58.0",
"@ivfuture/ecomm-types": "1.58.1",
"cross-env": "^7.0.3",

@@ -36,5 +36,5 @@ "jest": "^29.7.0",

"dependencies": {
"@ivfuture/ecomm-modules-sdk": "1.58.0"
"@ivfuture/ecomm-core": "2.70.1"
},
"gitHead": "0316a5b6db8ac9d784488999e6b3a804ae62858e"
"gitHead": "51656d6161670cd5fc2d90974cc5f2cf41fd097b"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc