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

@ai-lion/liondb

v6.1.21

Published

liondb是一个基于leveldb的本地磁盘存储数据库, 数据可以持久存储, 性能高效, 容量受限于磁盘大小

Downloads

394

Readme

LionDB 应用在本地应用的存储系统, 支持分布式运行

可以做单机持久存储或缓存, 基于google开源的leveldb之上做的封装

使用例子

nodejs环境

   
    // liondb.js ok
    import LionDB from "@ai-lion/liondb";
    
    //单个线程:
    let liondb = LionDB("path");

    //cluster 集群环境
    //const isMaster = cluster.isMaster;
    let liondb = LionDB.thread({filename:  'path', env: "cluster" | "electron" | "egg", isMaster: cluster.isMaster, thread: cluster.isMaster ? cluster : cluster.worker, });


    //阿里 egg 框架 集群环境: 定义 db.js
        const lionDB = require("@ai-lion/liondb");
        const cluster = require("cluster");

        let liondb;
        module.exports = (thread) => {
            if (liondb) return liondb;
            if (!thread) throw new Error("use liondb no thread");
            try {
                liondb = lionDB.clusterThread({ filename: ".liondb", env: "egg", isMaster: cluster.isMaster, thread: thread }, (err) => {
                    console.info("...........load ", err ? err.message : "");
                });
            } catch (err) {
                console.info("error load liondb ", err.message);
            }
            return liondb;
        };

    // agent.js //这个是egg框架内置的一个配置文件, 会 自动读取,优先加载,放在根目录 与 app.js同目录
        module.exports = async (agent) => {
            require("./liondb")(agent.messenger);
        };


    (async()=>{
        await liondb.set("aa", {name: 'aa'});
        let value = await liondb.get("aa);
        console.info("get ", value);
    })();


浏览器环境

 // 使用webpack 打包环境的
    import LionDB from "@ai-lion/liondb"; //@ai-lion/liondb/dist/browser
    或
    import LionDB = require("@ai-lion/liondb");  //@ai-lion/liondb/dist/browser

 // html页面直接引用: 
    https://cdn.jsdelivr.net/npm/@ai-lion/liondb/dist/liondb.js

api

    let liondb = LionDB("path");
    liondb.get("key"): Promise<any>;
    liondb.set("key", {name: "xxxxxx any value"}, ttl?);//ttl=过期时间, 单位秒
    liondb.increment("key", increment?, ttl?); //增量写入, increment=增量值, 默认1, ttl=过期时间, 单位秒
    liondb.del("key");
    liondb.count("key-*"): Promise<number>; //统计有多少个, 后辍的*表示通配符, 只能在最后使用
    liondb.find({key: "key-*", start: 0, limit: 100}): Promise<{key, value}[]>;//内容查找
    liondb.iterator({key: "key-*", start: 0, limit: 100}, async(key, value)=>{ //内容迭代查询
    });
    liondb.batch([{
        type: "put",//表示写入
        key: 'xxx',
        value: 'xxx'
    }, {
        type: "del",//表示删除
        key: 'aaa',
    }])