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

@zhike/cache-koa-middleware

Package Overview
Dependencies
Maintainers
11
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zhike/cache-koa-middleware - npm Package Compare versions

Comparing version 1.2.0 to 1.4.0

test/ttl-in-header.js

23

index.js

@@ -18,2 +18,7 @@ 'use strict';

const clientMaxAgeHeader = options.clientMaxAgeHeader;
if (clientMaxAgeHeader && typeof clientMaxAgeHeader !== 'string') {
throw new Error('options.clientMaxAgeHeader must be a string');
}
let keyFn = ctx => {

@@ -30,4 +35,3 @@ let sortedKeys = Object.keys(ctx.query).sort();

keyFn = options.keyGenerator;
}
else {
} else {
throw new Error('options.keyGenerator must be a function which returns a string as redis key');

@@ -41,4 +45,3 @@ }

skipCacheFn = options.skipCacheFn;
}
else {
} else {
throw new Error('options.skipCacheFn must be a function which returns a Promise');

@@ -52,4 +55,3 @@ }

throw new Error('options.commandTimeout must be an integer larger than zero');
}
else {
} else {
commandTimeout = options.commandTimeout;

@@ -72,7 +74,12 @@ }

ctx.set(response.headers);
if (clientMaxAgeHeader) {
let maxAge = await redis.ttl(redisKey).timeout(commandTimeout);
if (maxAge > 0) {
ctx.set(clientMaxAgeHeader, maxAge);
}
}
ctx.body = response.body;
return;
}
}
catch (e) {
} catch (e) {
// failed to get cache, move on

@@ -79,0 +86,0 @@ }

{
"name": "@zhike/cache-koa-middleware",
"version": "1.2.0",
"version": "1.4.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -92,2 +92,3 @@ const cache = require('../index')

it('2nd expire', function (done) {
this.timeout(5000);
setTimeout(() => {

@@ -94,0 +95,0 @@ request()

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