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 🙏

© 2025 – Pkg Stats / Ryan Hefner

jfcachedb

v1.0.32

Published

<font size=2>

Downloads

7

Readme

JFCacheDB

New support for uniapp in version 1.0.30 and above

summary

We can easily store the data on demand through the local storage and sessionstorage provided by the browser, but without a good plan, the cache index will be very long, the data will be confused, and you may inadvertently expose sensitive data. Jfcachedb came into being, which provides a rich interface, and you will be easy to use. Jfcachedb also provides automatic display of data in the development stage and automatic encryption of data in the production environment.

Install

npm i jfcachedb --save

table api

  • saveOrUpdate save or update table-key data
  • removeById remove data by table-key
  • get get table data by table-key

Usage

First, you need to define a data table. You can define a table configuration under config:

export default {
  table_session_sys: {
    tableName: '@table_session_sys',
    description: '测试',
    cacheType: 2 // 1 localStorage 2 sessionStorage
  }
}

Customize a way to develop a production environment:

function getDevCallback(devCallback = () => {}, proCallback = () => {}) {
  if (process.env.NODE_ENV === 'production') {
    return proCallback();
  } else if (process.env.NODE_ENV === 'development') {
    return devCallback();
  }
}

then you can build adbobject:

import JFcacheDB from 'jfcachedb';
let db = new JFcacheDB();
// support for uniapp
function UniappStorage() {
  this.removeItem = function(key) {
    try {
      uni.removeStorageSync(key);
    } catch (e) {}
  }
  this.getItem = function(key) {
    try {
      return uni.getStorageSync(key);
    } catch (e) {}
  }
  this.setItem = function(key, value) {
    try {
      uni.setStorageSync(key, val);
    } catch (e) {}
  }
  this.clear = function() {
    try {
      uni.clearStorageSync();
    } catch (e) {}
  }
}
db.bindStorage(new UniappStorage())
db.setEncryption({
  decodeData: (data) => {
    return getDevCallback(
      () => data,
      () => decodeUrl(data)
    );
  },
  encodeData: (data) => {
    return getDevCallback(
      () => data,
      () => encodeUrl(data)
    );
  },
  encodeTableName: (data) => {
    return getDevCallback(
      () => data,
      () => md5Encode(data)
    );
  },
});

let table = db.getTable(TableConst.table_session_sys);
let table2 = db.getTable(TableConst.table_local_xu);
table.saveOrUpdate('sansan', {
  age: 21,
  name: 'zansan',
  sex: '男',
  realName: '张三'
});
table2.saveOrUpdate('id', 'xxxxxuuuuuuuuu');
table2.saveOrUpdate('id2', '3333333');

Now, you can plan your data well and operate it conveniently.

  • table.saveOrUpdate update data,it will cover old data
  • table.removeById delete item
  • table.get To get the item, you can pass in an ID and get the corresponding value, such as:
table.get(id, [defaultValue])
  • table.getCacheData Get the data of the whole table, table description information, index, etc
  • table.dropCurrentTable drop table

Encryption and decryption can be defined by yourself, or you can use the following methods to introduce the 'crypto JS' Library:

import AES from "jfcachedb/crypto-js/aes";
import MD5 from "jfcachedb/crypto-js/md5";
import ENC from "jfcachedb/crypto-js/enc-latin1";
import MODE from "jfcachedb/crypto-js/mode-ecb";
import PKCS7 from "jfcachedb/crypto-js/pad-pkcs7";
import UTF8 from "jfcachedb/crypto-js/enc-utf8"

Specific use reference address https://www.npmjs.com/package/crypto-js

For further description, please refer to

https://www.cnblogs.com/SATinnovation/p/12909254.html

Contact me

Email: [email protected]

License

MIT Copyright (c) 2018 - forever Naufal Rabbani