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

ui-cache

v0.0.3

Published

Cache for SailFish

Downloads

26

Readme

七鱼缓存库

七鱼缓存层基于不可变数据模型设计, 引用关系来实现不同缓存之间的通信。七鱼缓存库实现如下两个功能:

  1. 实体列表 的存储
  2. 多个缓存的实例引用同一份数据源
  3. 不同缓存实例之间的通信

cache

注: 接入的时候, 可以根据需求, 使用不可变数据概念(Immutable.js)。

构建npm指令

  "dev": "webpack -p --config webpack.config.js",
  "test": "karma start karma.conf.js"

使用说明

  1. 保证数据的唯一性, 多个缓存的实例引用同一份数据源
  2. Hash实体以 id 为主键, 现不支持自定义
    // 继承 Super
    var SuperCache = function(options){
        this.init(options)
    }

    SuperCache.prototype = Object.create(Cache.prototype);

    // 实例化
    var supercache = new SuperCache({
        name : 'super'
    });

    // 初始化设置列表
    supercache.setListInCache([{id : 1, name : 1}], 'super-list-1');


    // 继承 Sofia
    var SofiaCache = function(options){
        this.init(options)
    }

    SofiaCache.prototype = Object.create(Cache.prototype);

    // 实例化
    var sofiacache = new SuperCache({
        name : 'sofia'
    });

    // 初始化设置列表
    sofiacache.setListInCache([{id : 'a', name : 'a'}], 'sofia-list-1');

接口说明

全局缓存接口

getCacheByName(name)

通过名称查询全局缓存中 对象

    // equal
    supercache.getCacheByName('super');

    sofiacache.getCacheByName('super');

getCacheList(name, key)

通过 名称 查询全局缓存中 列表值

    supercache.getCacheList('super', 'super-list-1')

    sofiacache.getCacheList('super', 'super-list-1')

getCacheHash(name, id)

通过 名称id 查询全局缓存中 哈希值

    supercache.getCacheHash('super', 1)

    sofiacache.getCacheHash('sofia', 'a')

列表缓存接口

setListInCache(array|object, key)

对列表数据的 添加更新, 并对Hash进行 添加更新

    // add list
    sofiacache.setListInCache([{id : 'a', name : 'a'}], 'sofia-list-1');

    // add object
    sofiacache.setListInCache({id : 'b', name : 'b'}, 'sofia-list-1');

    // sofia-list-1 : [{id : 'a', name : 'a'}, {id : 'b', name : 'b'}]

getListInCache(key)

通过列表 key 获取相应列表索引

    sofiacache.setListInCache([{id : 'a', name : 'a'}], 'sofia-list-1');
    sofiacache.getListInCache('sofia-list-1');

    // list : [{id : 'a', name : 'a'}]

saveItemToCache(array|object)

保存数据项到 Hash

    // add list
    sofiacache.saveItemToCache([{id : 'a', name : 'a'}]);

    // add object
    sofiacache.saveItemToCache({id : 'b', name : 'b'});

    // hash: {a : {id : 'a', name : 'a'}, b : {id : 'b', name : 'b'}}

unshiftItemInCache(array|object, key)

前向插入数据到 key 列表

    // add list
    sofiacache.unshiftItemInCache([{id : 'a', name : 'a'}], 'sofia-list-1');

    // add object
    sofiacache.unshiftItemInCache({id : 'b', name : 'b'}, 'sofia-list-1');

    // sofia-list-1: [{id : 'b', name : 'b'}, {id : 'a', name : 'a'}]

deleteDataInCache(id)

同时删除 列表 中数据 和 Hash 中数据

    sofiacache.setListInCache([{id : 'a', name : 'a'}], 'sofia-list-1');

    sofiacache.deleteDataInCache('a');

    // hash : {}, list : []

removeItemInCache(id, key)

仅删除 key 列表中, id 的数据项, 不删除Hash中数据

    sofiacache.setListInCache([{id : 'a', name : 'a'}], 'sofia-list-1');

    sofiacache.removeItemInCache('a', 'unshift');

    // hash : {a : {id : 'a', name : 'a'}}, list : []