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

@appolo/cache

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appolo/cache - npm Package Compare versions

Comparing version 7.0.4 to 7.0.5

16

module/src/cache.js

@@ -6,2 +6,3 @@ "use strict";

const appolo_cache_1 = require("appolo-cache");
const _ = require("lodash");
const ResultSymbol = "@result";

@@ -124,4 +125,15 @@ let Cache = class Cache {

_getRedisMaxAge() {
return Math.floor((this._options.dbMaxAge || this._options.maxAge) / 1000);
let age = Math.floor((this._options.dbMaxAge || this._options.maxAge) / 1000);
if (this._options.randomAge) {
age += _.random(0, this._options.randomAge);
}
return age;
}
_getMemoryMaxAge() {
let age = this._options.maxAge;
if (this._options.randomAge) {
age += _.random(0, this._options.randomAge);
}
return age;
}
_getRedisKey(key) {

@@ -165,3 +177,3 @@ if (typeof key != "string") {

let dto = value && value.hasOwnProperty && value.hasOwnProperty(ResultSymbol) ? value : { [ResultSymbol]: value };
this._cache.set(key, this._options.clone ? JSON.stringify(dto) : dto, this._options.maxAge);
this._cache.set(key, this._options.clone ? JSON.stringify(dto) : dto, this._getMemoryMaxAge());
}

@@ -168,0 +180,0 @@ _setRedisValue(key, value) {

@@ -5,2 +5,3 @@ import {define, initMethod, inject, injectLazy} from 'appolo';

import {ILogger} from "@appolo/logger";
import * as _ from "lodash";
import {IInnerCacheOptions, IOptions} from "./IOptions";

@@ -191,5 +192,21 @@ import Timer = NodeJS.Timer;

private _getRedisMaxAge(): number {
return Math.floor((this._options.dbMaxAge || this._options.maxAge) / 1000)
let age = Math.floor((this._options.dbMaxAge || this._options.maxAge) / 1000);
if (this._options.randomAge) {
age += _.random(0, this._options.randomAge)
}
return age;
}
private _getMemoryMaxAge(): number {
let age = this._options.maxAge
if (this._options.randomAge) {
age += _.random(0, this._options.randomAge)
}
return age
}
private _getRedisKey(key: any): string {

@@ -253,3 +270,3 @@ if (typeof key != "string") {

this._cache.set(key, this._options.clone ? JSON.stringify(dto) : dto, this._options.maxAge);
this._cache.set(key, this._options.clone ? JSON.stringify(dto) : dto, this._getMemoryMaxAge());
}

@@ -256,0 +273,0 @@

@@ -17,2 +17,3 @@ import {IModuleOptions} from 'appolo';

}

@@ -49,2 +50,3 @@

cacheNull?: boolean
randomAge?: number

@@ -51,0 +53,0 @@ }

2

package.json
{
"name": "@appolo/cache",
"version": "7.0.4",
"version": "7.0.5",
"description": "appolo cache module",

@@ -5,0 +5,0 @@ "publishConfig": {

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