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

@acuris/leprechaun-cache

Package Overview
Dependencies
Maintainers
4
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@acuris/leprechaun-cache - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

1

dist/leprechaun-cache.d.ts

@@ -22,3 +22,2 @@ import { Cacheable, LeprechaunCacheOptions } from './types';

private spinLock;
private getLock;
private updateCache;

@@ -25,0 +24,0 @@ private unlock;

24

dist/leprechaun-cache.js

@@ -46,3 +46,3 @@ "use strict";

async refresh(key) {
return this.updateCache(key, this.softTtlMs, true);
return this.updateCache(key, this.softTtlMs);
}

@@ -52,3 +52,3 @@ async doGet(key, ttl) {

if (!result) {
return this.updateCache(key, ttl, true);
return this.updateCache(key, ttl);
}

@@ -58,3 +58,9 @@ if (result.expiresAt > Date.now()) {

}
const update = this.updateCache(key, ttl, !this.returnStale);
const update = this.updateCache(key, ttl).catch(e => {
if (this.returnStale) {
this.onBackgroundError(e);
return result.data;
}
throw e;
});
if (!this.returnStale) {

@@ -94,12 +100,4 @@ return update;

}
async getLock(key, doSpinLock) {
return doSpinLock
? this.spinLock(key)
: {
lockId: (await this.cacheStore.lock(this.keyPrefix + key, this.lockTtlMs)) || '',
didSpin: false
};
}
async updateCache(key, ttl, doSpinLock) {
const lock = await this.getLock(key, doSpinLock);
async updateCache(key, ttl) {
const lock = await this.spinLock(key);
if (!lock.lockId) {

@@ -106,0 +104,0 @@ throw new Error('unable to acquire lock and no data in cache');

{
"name": "@acuris/leprechaun-cache",
"version": "0.0.11",
"version": "0.0.12",
"private": false,

@@ -5,0 +5,0 @@ "description": "Caching library that supports double checked caching and stale returns to avoid stampede and slow responses",

@@ -79,3 +79,3 @@ import { CacheStore, Cacheable, OnCacheMiss, LeprechaunCacheOptions, CacheItem } from './types'

public async refresh(key: string): Promise<T> {
return this.updateCache(key, this.softTtlMs, true)
return this.updateCache(key, this.softTtlMs)
}

@@ -86,3 +86,3 @@

if (!result) {
return this.updateCache(key, ttl, true)
return this.updateCache(key, ttl)
}

@@ -94,4 +94,11 @@

const update = this.updateCache(key, ttl, !this.returnStale)
const update = this.updateCache(key, ttl).catch(e => {
if (this.returnStale) {
this.onBackgroundError(e)
return result.data
}
throw e
})
if (!this.returnStale) {

@@ -138,14 +145,5 @@ return update

private async getLock(key: string, doSpinLock: boolean): Promise<LockResult> {
return doSpinLock
? this.spinLock(key)
: {
lockId: (await this.cacheStore.lock(this.keyPrefix + key, this.lockTtlMs)) || '',
didSpin: false
}
}
private async updateCache(key: string, ttl: number): Promise<T> {
const lock = await this.spinLock(key)
private async updateCache(key: string, ttl: number, doSpinLock: boolean): Promise<T> {
const lock = await this.getLock(key, doSpinLock)
if (!lock.lockId) {

@@ -152,0 +150,0 @@ throw new Error('unable to acquire lock and no data in cache')

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