npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tank-cache

v1.1.14

Published

This is a file cache plug-in based on nodejs

Downloads

19

Readme

English | 中文

tank-cache

This is a file cache plug-in based on nodejs

install

npm install --save tank-cache

examples

//import tank-cache
const FileCache = require("tank-cache/index")

//default savePath process.cwd()+".runtime/cache.json"
const cache = new FileCache()
//use savePath
const cache = new FileCache(".runtime/mycache.json")
//store 
cache.store("tank", "man", 1)
// or 
cache.set("tank", "man", 1)

apis

constructor(saveFilePath: any);

* @param saveFilePath? default: ".runtime/cache.json"
* @example
* //use default savePath ".runtime/cache.json"
* const cache = new FileCache()
* //use my savePath
* const cache = new FileCache(".runtime/mycache.json")
* output path=process.cwd()+savePath
* @constructor

has(key: any): any;

has Determine if an item exists in the cache.

@param key
@return {boolean}
@example
     cache.has("tank")
@Function

get(key: any, defaultVal?: any): string | null;

get Retrieve an item from the cache by key.

* @param key
* @param defaultVal?
* @return {string|null}
* @Function

forever(key: any, val: any): void;

forever store an item in the cache indefinitely.

@param key
@param val
@example
     cache.forever("tank","nice")
@Function

forget(key: any): null | any;

forget remove an item from the cache.

@param key
@return {null|*}
@example
    cache.forget("tank","nice")
@Function

pull(key: any): string;

pull Retrieve an item from the cache and delete it.

@param key
@example
    cache.pull("tank")
@Function

store(key: any, val?: any, ttl?: number): any;

set store an item in the cache for a given number of seconds.

@param key
@param val
@param ttl Second
@return {*}
@example
   cache.store("tank", "man", 1)
@Function

set(key: any, val?: any, ttl?: number): any;

set store an item in the cache for a given number of seconds. as same store function

@param key
@param val
@param ttl Second
@return {*}
@example
   cache.set("tank", "man", 1)
@Function

add(key: any, val?: any, ttl?: number): boolean;

The add method will only store data that does not exist in the cache. If the storage is successful, it will return true, otherwise it will return false:

@param key
@param val
@param ttl
@return {boolean}
@example
   cache.add("tank", "man", 1)
@Function

flush(): void;

flush remove all items from the cache.

@example
   cache.flush()
@Function

forgetByKeys(keys: string | string[]): void;

@param keys {string|string[]}
@function

flushByPrefix(prefix?: string): void;

remove the cache according to the prefix

@param prefix {string}
@function

incrementTll(key: any, ttl?: number): void;

Increase the validity period

@param ttl {Number} Second
@Function

ttl(key: any): number;

get the remaining time to live

@param key
@return {number}  millisecond
@function
@Function

getKeys(prefix?: string): string[];

get all keys or filter by prefix

@param prefix? {string}
@return string[]
@Function