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

@beautywe/plugin-storage

v1.0.0

Published

Storage plugin for beautywe

Downloads

10

Readme

介绍

CircleCI NPM Version NPM Downloads npm bundle size Coverage Status

Feature

  1. 过期控制
  2. 版本隔离

安装

$ npm i @beautywe/plugin-storage
import { BtApp } from '@beautywe/core';
import storage from '@beautywe/plugin-storage';

const app = new BtApp();
app.use(storage({
    // options
}))

使用

app.storage.set(key, value, options);
app.storage.get(key, options);
app.storage.remove(key);
app.storage.clear();

storage(options)

options.expire

设置缓存时间,默认是 7 ,单位是「天」

options.appVersion

设置当前应用的版本号,后续的所有缓存,都会关联到当前版本号中,并且会有版本隔离:

app.use({ appVersion: '0.0.1' });
app.set('name', 'jc');

// 返回 jc
app.get('name');

// 当版本更新后
app.use({ appVersion: '0.0.2' });

// 返回 undefined;
app.get('name');

set(key, value, options)

key

要设置的缓存名

value

要设置的缓存

options.expire

缓存的过期时间,默认跟 stoarge(options) 设置的一致。

options.appVersion

缓存的对应应用版本,默认跟 storage(options) 设置的一致。

get(key, options)

key

获取的缓存名

options.appVersion

缓存的对应应用版本,默认跟 storage(options) 设置的一致。

options.ignoreVersion

是否忽略版本检查,默认为 false,设置为 true 时,则返回的缓存不做版本检查

options.ignoreExpire

是否忽略过期时间检查,默认为 false,设置为 true 时,则返回的缓存不做过期时间检查

remove(key)

清除特定的缓存

clear()

清除所有缓存