New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@qest/cache-async-adapter

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qest/cache-async-adapter

Async cache Redis or local with the same interface which can be further expanded

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

Cache

Async cache Redis or local with the same interface which can be further expanded

Use memory storage

import {CacheAdapterType, CacheFactory} from "@qest/cache-async-adapter";

const cacheLocal = new CacheFactory().create(CacheAdapterType.Local);

await cacheLocal.set('key1', {data: 'hello'}, 10000); // time in ms
console.log(await cacheLocal.get('key1')); // {data: 'hello'}

Use Redis storage

import {CacheAdapterType, CacheFactory} from "@qest/cache-async-adapter";
const redisConfig = {
    port: 6379,
    host: '127.0.0.1',
};

const cacheRedis =  new CacheFactory().create(CacheAdapterType.Redis, redisConfig);

await cacheRedis.set('key1', {data: 'hello Redis'}, 10000); // time in ms
console.log(await cacheRedis.get('key1')); // {data: 'hello Redis'}

All functions

get: (key: string) => Promise;

Example:

await cacheLocal.get('key1')
set: (key: string, values: object, msInterval?: number) => Promise;

Example:

await cacheLocal.set('key1', {data: 'hello'}, 10000); // time in ms
invalidate: (key: string) => Promise;

Example:

await cacheLocal.invalidate('key1')
invalidateAll: () => Promise;

Example:

await cacheLocal.invalidateAll()
scan: (key: string) => Promise<T[]>;

Example:

await cacheLocal.set('key1', {data: '1'}); 
await cacheLocal.set('key2', {data: '2'});
cacheRedis.scan(`key:*`); // return [key1: {data: 1}', key2: {data: 2}]   

scanKeys: (regex: string) => Promise<string[]>;

Example:

await cacheLocal.set('key1', {data: 'hello'}); 
await cacheLocal.set('key2', {data: 'hello'});
cacheRedis.scanKeys(`key:*`); // return ['key1', 'key2']    

invalidateByKeys: (keys: string[]) => Promise;

Example:

await cacheLocal.invalidateByKeys(['key1'])

FAQs

Package last updated on 04 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts