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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ag-cache

v1.0.1

Published

基于TypeScript实现,可应用于React,Angular,Vue,JavaScript等web环境的缓存模块。

Downloads

6

Readme

ag-cache

基于TypeScript实现,可应用于React,Angular,Vue,JavaScript等web环境的缓存模块。更好的管理您的缓存信息,灵活的更换缓存所处的位置。

Documentation in English

更改日志

安装

yarn

yarn add ag-cache

or npm

npm install ag-cache

基础文档

API文档

实例化 CacheModule

new Cache(CacheOptions)

CacheOptions

属性 | 类型 | 默认值 | 描述 ---|---|---|--- key | string | | 关联该cache的唯一值,例如可以是用户ID defaultExpires | number | 200 | 毫秒单位,指定默认的缓存超时时间,0则不超时 defaultLevel | 'RAM', 'COOKIE', 'SESSION_STORAGE', 'LOCAL_STORAGE' | 'RAM' | 默认的缓存级别 defaultCollectorInterval | number | 30000 | 垃圾回收的执行间隔,只回收超时缓存 maximum | CacheMaximum | 可选 | 设置各级缓存最大内存占用,0则为不限制 debug | boolean | false | 启用debug调试模式

实例方法

set 设置缓存

使用:set(key, value, option): Promise<void>

参数名 | 类型 | 默认值 | 描述 ---|---|---|--- key | string | | 缓存对应的唯一key value | CacheValue | | 缓存值 option | {level, expires} | 默认为CacheOptions所对应的defaultExpires及defaultLevel | 设置缓存的级别与超时时间

get 读取缓存

使用:get<T = any>(key, level): T

参数名 | 类型 | 默认值 | 描述 ---|---|---|--- key | string | | 缓存对应的key level | 'RAM', 'COOKIE', 'SESSION_STORAGE', 'LOCAL_STORAGE' | 可选 | 如果没有指定则会从所有级别缓存内找到首个匹配项返回,如果指定则从指定级别缓存内查询

delete 移除指定key的缓存信息

使用:delete(key, level): void

参数名 | 类型 | 默认值 | 描述 ---|---|---|--- key | string | | 缓存对应的key level | 'RAM', 'COOKIE', 'SESSION_STORAGE', 'LOCAL_STORAGE' | 可选 | 如果没有指定则会从所有级别缓存内移除首个匹配项,如果指定则从指定级别缓存内移除匹配项

clear 清除指定级别的缓存信息

使用: clear(level: CacheLevel): void

参数名 | 类型 | 默认值 | 描述 ---|---|---|--- level | 'RAM', 'COOKIE', 'SESSION_STORAGE', 'LOCAL_STORAGE' | | 清空指定级别缓存内的所有缓存信息

clearAll 清除所有缓存信息

使用: clearAll(): void