🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

pinia-cache-plugin

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pinia-cache-plugin

pinia state cache plugin (pinia状态持久化缓存插件)

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

pinia-cache-plugin

pinia state cache plugin (pinia 状态持久化缓存插件)

通过 localStorage 缓存 pinia 状态。

安装

npm install pinia-cache-plugin

使用

import { createPinia } from 'pinia';
import piniaCachePlugin from 'pinia-cache-plugin';

const store = createPinia();

// 默认参数
/* {
  allCache: false,
  excludeNameArray: [],
  cacheNameArray: [],
  cacheNameExpire: {
    defaultExpire: 'local',
  },
}, */
store.use(piniaCachePlugin(options));

参数介绍

{
  // 是否缓存所有状态,默认不缓存
  allCache: boolean;
  // 排除状态 storeId,默认不排除
  excludeNameArray: string[];
  // 缓存状态 storeId,默认不缓存
  cacheNameArray: string[];
  // 缓存时间,默认 local (持久保存)
  // 可以设置过期时间数值,单位为毫秒(多少毫秒后过期)
  cacheNameExpire: {
    // 默认使用状态
    defaultExpire: 'local',
    // 单独设置状态(优先)
    [key: string]: 'local' | number
  };
}

Keywords

pinia

FAQs

Package last updated on 15 Nov 2023

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