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

online-mgr

v0.0.2

Published

distributed service online-mgr use redis set

Downloads

2

Readme

online-mgr

distributed service online-mgr use redis set

分布式在线用户管理器

使用redis集合(set)结构,将通讯服的ID作为set的key,将在该通讯服中的userId放入set集合中

需求分析

系统中使用了第三方充值系统,会不断的扫描第三方充值结果. 扫到结果后,需要通知玩家充值成功.那么就需要获得玩家的通讯服.(当然不在线就不处理了) 使用redis做在线用户管理器的方案有4种之多:zset,set,HyperLogLog和位图,从空间和功能两方面考虑,优劣各有.

我们用的是分布式系统,user们会处于不同的通讯服(connectors) 于是选择使用redis集合(set)结构,将通讯服的ID作为set的key,将在该通讯服中的userId放入set集合中 结构就像这样

  conn1   :   [userId1...userIdn],
  conn2   :   [userId1...userIdn],
  conn3   :   [userId1...userIdn],

适用场景

该管理器(叫插件也行),相比HyperLogLog和位图会占用更大的空间,但会存储connId. 基本能适用绝大多数的在线管理需求. 如果需要用redis做几日存留的计算统计,可自行扩展该插件,或在该插件外部自行处理.

安装

npm i online-mgr --save

支持方法

新增在线

@param sid   connId
@param uid   userId
addOnlineUser(sid, uid)

删除在线

@param sid   connId
@param uid   userId
remOnlineUser(sid, uid)

获得在线用户列表

@param sid   connId
getOnlineUsers(sid)

获得在线用户数量

@param sid   connId
getOnlineNum(sid)

检测是否在线

@param uid
isOnline(uid)

获得玩家所在的通讯服id

@param uid
getSidByUid(uid)

清空在线记录

cleanOnlineUsers()