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

tabby-cache

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tabby-cache

The smallest cache library that actually works. \ `37` lines of code, `0` dependencies

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
2
Created
Source

tabby-cache

The smallest cache library that actually works.
37 lines of code, 0 dependencies

Installation

Current stable version: 1.0

$ npm install tabby-cache

Usage

const TabbyCache = require('tabby-cache');
const cache = new TabbyCache(60); // in seconds

const obj = 'object'; // string, number, boolean, object, array
cache.set(obj, 'cache-key'); // set the cache

// cache that exists
cache.get('cache-key'); // return obj

// cache that doesn't exists
cache.get('cache'); // return undefined

Example:

const TabbyCache = require('tabby-cache');
const cache = new TabbyCache(300);
const fetch = require('node-fetch');

async function TabbyApi() {
    const getCache = cache.get('tabby-api');
    if (getCache == undefined) {
        const { users, servers } = await fetch('https://api.tabbybot.eu/').then(res => res.json());
        cache.set(users, 'tabby-api');
    } else {
        cache.get('tabby-api');
    };
};

Keywords

cache

FAQs

Package last updated on 18 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