New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cacheable

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cacheable - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

4

dist/index.d.ts

@@ -118,2 +118,3 @@ import { Keyv, KeyvStoreAdapter } from 'keyv';

nonBlocking?: boolean;
ttl?: number;
};

@@ -124,2 +125,3 @@ declare class Cacheable extends Hookified {

private _nonBlocking;
private _ttl?;
private readonly _stats;

@@ -134,2 +136,4 @@ constructor(options?: CacheableOptions);

set nonBlocking(nonBlocking: boolean);
get ttl(): number | undefined;
set ttl(ttl: number | undefined);
setPrimary(primary: Keyv | KeyvStoreAdapter): void;

@@ -136,0 +140,0 @@ setSecondary(secondary: Keyv | KeyvStoreAdapter): void;

26

dist/index.js

@@ -493,2 +493,3 @@ // src/index.ts

_nonBlocking = false;
_ttl;
_stats = new CacheableStats({ enabled: false });

@@ -509,2 +510,5 @@ constructor(options) {

}
if (options?.ttl) {
this._ttl = options.ttl;
}
}

@@ -532,2 +536,8 @@ get stats() {

}
get ttl() {
return this._ttl;
}
set ttl(ttl) {
this._ttl = ttl;
}
setPrimary(primary) {

@@ -547,3 +557,3 @@ this._primary = primary instanceof Keyv ? primary : new Keyv(primary);

if (result) {
await this._primary.set(key, result);
await this._primary.set(key, result, this._ttl);
}

@@ -581,3 +591,3 @@ }

result[i] = secondaryResult[i];
await this._primary.set(key, secondaryResult[i]);
await this._primary.set(key, secondaryResult[i], this._ttl);
}

@@ -604,8 +614,9 @@ }

let result = false;
const finalTtl = ttl ?? this._ttl;
try {
await this.hook("BEFORE_SET" /* BEFORE_SET */, { key, value, ttl });
await this.hook("BEFORE_SET" /* BEFORE_SET */, { key, value, finalTtl });
const promises = [];
promises.push(this._primary.set(key, value, ttl));
promises.push(this._primary.set(key, value, finalTtl));
if (this._secondary) {
promises.push(this._secondary.set(key, value, ttl));
promises.push(this._secondary.set(key, value, finalTtl));
}

@@ -618,3 +629,3 @@ if (this._nonBlocking) {

}
await this.hook("AFTER_SET" /* AFTER_SET */, { key, value, ttl });
await this.hook("AFTER_SET" /* AFTER_SET */, { key, value, finalTtl });
} catch (error) {

@@ -773,3 +784,4 @@ await this.emit("error" /* ERROR */, error);

for (const item of items) {
promises.push(keyv.set(item.key, item.value, item.ttl));
const finalTtl = item.ttl ?? this._ttl;
promises.push(keyv.set(item.key, item.value, finalTtl));
}

@@ -776,0 +788,0 @@ await Promise.all(promises);

{
"name": "cacheable",
"version": "1.1.0",
"version": "1.2.0",
"description": "Simple Caching Engine using Keyv",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is not supported yet

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