protocat
Advanced tools
Comparing version 0.5.0-beta.1 to 0.5.0
@@ -6,4 +6,11 @@ /// <reference types="node" /> | ||
export interface CacheImplementation<E = {}> { | ||
/** | ||
* Create a unique cache key that will be used for response save and lookup. | ||
* | ||
* Return falsy key if caching should be skipped | ||
*/ | ||
hash: (call: ProtoCatCall<E, Message, Message, CallType.Unary>) => Promise<string | undefined> | string | undefined; | ||
/** Return buffer from cache. Returning falsy value is considered a cache miss. */ | ||
get: (key: string, call: ProtoCatCall<E, Message, Message, CallType.Unary>) => Promise<Buffer | undefined> | Buffer | undefined; | ||
/** Set cache result. Result is not awaited and does not block the response nor subsequent requests */ | ||
set: (key: string, value: Buffer, call: ProtoCatCall<E, Message, Message, CallType.Unary>) => void; | ||
@@ -10,0 +17,0 @@ } |
@@ -5,3 +5,7 @@ "use strict"; | ||
const call_types_1 = require("../../call-types"); | ||
exports.createCache = (cache, cb) => async (call, next) => { | ||
exports.createCache = ( | ||
/** Response binary cache implementation */ | ||
cache, | ||
/** Optional callback to react on cache miss/hit. Called once per request ASAP after cache retrieval */ | ||
cb) => async (call, next) => { | ||
if (call.type !== call_types_1.CallType.Unary) | ||
@@ -8,0 +12,0 @@ return next(); |
{ | ||
"name": "protocat", | ||
"description": "Modern, minimalist type-safe gRPC framework for Node.js", | ||
"version": "0.5.0-beta.1", | ||
"version": "0.5.0", | ||
"author": "Jaroslav Šmolík <grissius@gmail.com>", | ||
@@ -6,0 +6,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
207960
3033