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

lazy-kit-redis

v1.0.1

Published

> redis quick toolkit based on Nodejs

Downloads

7

Readme

lazy-kit-memory

redis quick toolkit based on Nodejs

Functions

/**
 * 获取Redis实例
 * @param options 连接参数, JSON或者URL
 * @param autoConn 是否自动连接, 默认true
 * @returns 
 */
function redis(options:any, autoConn?:boolean): Promise<Redis>;

/**
 * Redis
 * URL: redis[s]://[[username][:password]@][host][:port][/db-number]
 */
class Redis {
  constructor(options:any|string);
  /**
   * 创建连接
   * @returns 
   */
  connect(): Promise<void>;
  /**
   * 设置字符串
   * @param k 
   * @param v 
   */
  set(k:string, v:any): Promise<void>;
  /**
   * 通过主键获取字符串
   * @param k 
   * @returns string
   */
  get(k:string): Promise<string>;
  /**
   * 通过主键返回一个指定为JSON的对象
   * @param k 
   * @returns 
   */
  getJson(k:string): Promise<any>;
  /**
   * 设置哈希对象, 不检查字段唯一
   * @param map 哈希主键
   * @param k 字段
   * @param v 值
   * @returns number
   */
  hSet(map:string, k:string, v:any): Promise<number>;
  /**
   * 设置哈希对象, 检查字段唯一
   * @param map 哈希主键
   * @param k 字段
   * @param v 值
   * @returns boolean
   */
  hUniSet(map:string, k:string, v:any): Promise<boolean>;
  /**
   * 通过哈希主键、获取指定字段的值
   * @param map 哈希
   * @param k 字段
   * @returns 
   */
  hGet(map:string, k:string): Promise<string>;
  /**
   * 通过哈希主键、获取指定字段的JSON对象
   * @param map 哈希
   * @param k 字段
   * @returns 
   */
  hGetJson(map:string, k:string): Promise<any>;
  /**
   * 获取指定哈希主键的全部字段
   * @param map 哈希
   * @returns JSON
   */
  hGets(map:string): Promise<any>;
  /**
   * 删除置顶哈希的字段
   * @param map 哈希
   * @param k 字段
   * @returns 删除个数
   */
  hDel(map:string, k:string): Promise<number>;
  /**
   * 根据哈希的字段进行模糊删除 - 包含
   * @param map 哈希
   * @param keyLike 查询条件 - 字段
   */
  hDelByKeyLike(map:string, keyLike:string): Promise<void>;
  /**
   * 根据哈希的字段进行模糊删除 - 起始于
   * @param map 哈希
   * @param keyLike 
   */
  hDelByKeyStartsWith(map:string, keyLike:string): Promise<void>;
  /**
   * 根据哈希的字段进行模糊删除 - 结尾于
   * @param map 哈希
   * @param keyLike 查询条件 - 字段
   */
  hDelByKeyEndsWith(map:string, keyLike:string): Promise<void>;
  /**
   * 检查哈希的指定字段的值, 是否符合查询条件
   * @param map 哈希
   * @param key 字段
   * @param filter 查询条件, 当是string|number的时候, key对应的值与filter进行比较; 是JSON的时候, 遍历filter比较每一个指定的KV
   * @returns 
   */
  hExists(map:string, key:string, filter?:{[field:string]:string|number}|string|number): Promise<boolean>;
  /**
   * 获取哈希中所有的Keys
   * @param map 哈希
   * @returns 
   */
  hKeys(map:string): Promise<string[]>;
  /**
   * 获取Hash中所有的Values
   * @param map 哈希
   * @returns 
   */
  hVals(map:string): Promise<string[]>;
  /**
   * 根据指定key进行模糊查询 - 包含
   * @param map 哈希
   * @param keyLike 查询条件 - 字段
   * @returns 
   */
  hGetByKeyLike(map:string, keyLike:string): Promise<any>;
  /**
   * 根据指定key进行模糊查询 - 起始于
   * @param map 哈希
   * @param keyLike 查询条件 - 字段
   * @returns 
   */
  hGetByKeyStartsWith(map:string, keyLike:string): Promise<any>;
  /**
   * 根据指定key进行模糊查询 - 结尾于
   * @param map 哈希
   * @param keyLike 查询条件 - 字段
   * @returns 
   */
  hGetByKeyEndsWith(map:string, keyLike:string): Promise<any>;
  /**
   * 根据指定的value(JSON)中的field进行查找
   * @param map 哈希
   * @param field 哈希中字段对应的JSON中的KEY
   * @param value 哈希中字段对应的JSON中的VALUE
   * @returns 
   */
  hGetByJson(map:string, field:string, value:string|number, beLike?:boolean): Promise<any>;
  /**
   * 根据指定的value(JSON)中的field(深度查询)进行查找
   * @param map 哈希
   * @param field 哈希中字段对应的JSON中的KEY -- 深度, ex: a.b.c
   * @param value 需要判断的值
   * @param beLike 是否是模糊查询
   * @returns 
   */
  hGetByJsonInDeep(map:string, field:string, value:string|number, beLike?:boolean): Promise<any>;
  /**
   * 更新指定的key的value(JSON)中的field对应的值
   * 指定的key不存在时新增
   * @param map 哈希
   * @param key 字段
   * @param field 字段对应的JSON中的KEY
   * @param value 字段对应的JSON中的VALUE
   * @param addIfNotExist 哈希的字段不存在时是否新增, 默认false 
   */
  hUpdByJson( map:string, key:string, field:string, value:string|number, addIfNotExist=false ): Promise<void>;
  /**
   * 更新指定的key的value(JSON)中的field对应的值
   * 指定的key不存在时新增
   * @param map 哈希
   * @param key 字段
   * @param set 字段对应的JSON
   * @param addIfNotExist 哈希的字段不存在时是否新增, 默认false
   */
  hUpdByJsonSet( map:string, key:string, set:{[field:string]:string|number}, addIfNotExist=false ): Promise<void>;

  /**
   * 关闭连接
   */
  close(): Promise<void>;
  /**
   * This returns true when the client's underlying socket is open, and false when it isn't 
   * @returns 
   */
  isOpen(): boolean;
  /**
   * To check if the the client is connected and ready to send commands
   * @returns boolean
   */
  isReady(): boolean;
  /**
   * 批处理
   * @param cmds {
      action:string;  处理类型, 支持set、get、del、hset、hget、hdel、hkeys、hvals
      args:any[];     处理输入参数, set(key,value)、get(key)、del(key)、hset(map,key,value)、hget(map,key)、hdel(map,key)、hkeys(map)、hvals(map)
    }[]
  * @returns 
  */
  transact(cmds:{
    action:string;
    args:any[]
  }[]): Promise<any[]>;
}