Sign In

@arcjet/cache

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arcjet/cache - npm Package Compare versions

Comparing version
1.9.1
to
1.10.0-rc.0
+32
-32
dist/index.d.ts
//#region src/index.d.ts
/**
* Interface for a cache.
*/
* Interface for a cache.
*/
interface Cache<T = unknown> {
/**
* Retrieve a value from the cache;
* it will be returned with the remaining time-to-live (in seconds) if it exists.
*
* @param namespace
* Isolated segment of the cache where keys are tracked.
* @param key
* Key.
* @returns
* Promise for a tuple with the value and TTL in seconds;
* value will be `undefined` and TTL will be `0` if not found.
*/
* Retrieve a value from the cache;
* it will be returned with the remaining time-to-live (in seconds) if it exists.
*
* @param namespace
* Isolated segment of the cache where keys are tracked.
* @param key
* Key.
* @returns
* Promise for a tuple with the value and TTL in seconds;
* value will be `undefined` and TTL will be `0` if not found.
*/
get(namespace: string, key: string): Promise<[T | undefined, number]>;
/**
* Store a value in the cache.
*
* @param namespace
* Isolated segment of the cache where keys are tracked.
* @param key
* Key.
* @param value
* Value.
* @param ttl
* Number of seconds the entry stays valid.
* @returns
* Nothing.
*/
* Store a value in the cache.
*
* @param namespace
* Isolated segment of the cache where keys are tracked.
* @param key
* Key.
* @param value
* Value.
* @param ttl
* Number of seconds the entry stays valid.
* @returns
* Nothing.
*/
set(namespace: string, key: string, value: T, ttl: number): void;

@@ -43,12 +43,12 @@ }

/**
* In-memory cache.
*/
* In-memory cache.
*/
declare class MemoryCache<T> implements Cache<T> {
/**
* Data.
*/
* Data.
*/
namespaces: Map<string, Bucket<T>>;
/**
* Create a new in-memory cache.
*/
* Create a new in-memory cache.
*/
constructor();

@@ -55,0 +55,0 @@ get(namespace: string, key: string): Promise<[T | undefined, number]>;

{
"name": "@arcjet/cache",
"version": "1.9.1",
"version": "1.10.0-rc.0",
"description": "Arcjet cache interface and implementations",

@@ -45,3 +45,3 @@ "keywords": [

"build": "tsdown",
"typecheck": "tsgo --noEmit",
"typecheck": "tsc --noEmit",
"test-api": "node --test -- test/*.test.ts",

@@ -53,4 +53,4 @@ "test-coverage": "node --experimental-test-coverage --test -- test/*.test.ts",

"devDependencies": {
"tsdown": "0.22.3",
"typescript": "6.0.3"
"tsdown": "0.22.7",
"typescript": "7.0.2"
},

@@ -57,0 +57,0 @@ "engines": {