cache

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UserTodayUploadTrafficCacheKey 用户当日上传流量
	UserTodayUploadTrafficCacheKey = "node:user_today_upload_traffic"
	// UserTodayDownloadTrafficCacheKey 用户当日下载流量
	UserTodayDownloadTrafficCacheKey = "node:user_today_download_traffic"
	// UserTodayTotalTrafficCacheKey 用户当日总流量
	UserTodayTotalTrafficCacheKey = "node:user_today_total_traffic"
	// NodeTodayUploadTrafficCacheKey 节点当日上传流量
	NodeTodayUploadTrafficCacheKey = "node:node_today_upload_traffic"
	// NodeTodayDownloadTrafficCacheKey 节点当日下载流量
	NodeTodayDownloadTrafficCacheKey = "node:node_today_download_traffic"
	// NodeTodayTotalTrafficCacheKey 节点当日总流量
	NodeTodayTotalTrafficCacheKey = "node:node_today_total_traffic"
	// UserTodayUploadTrafficRankKey 用户当日上传流量排行榜
	UserTodayUploadTrafficRankKey = "node:user_today_upload_traffic_rank"
	// UserTodayDownloadTrafficRankKey 用户当日下载流量排行榜
	UserTodayDownloadTrafficRankKey = "node:user_today_download_traffic_rank"
	// UserTodayTotalTrafficRankKey 用户当日总流量排行榜
	UserTodayTotalTrafficRankKey = "node:user_today_total_traffic_rank"
	// NodeTodayUploadTrafficRankKey 节点当日上传流量排行榜
	NodeTodayUploadTrafficRankKey = "node:node_today_upload_traffic_rank"
	// NodeTodayDownloadTrafficRankKey 节点当日下载流量排行榜
	NodeTodayDownloadTrafficRankKey = "node:node_today_download_traffic_rank"
	// NodeTodayTotalTrafficRankKey 节点当日总流量排行榜
	NodeTodayTotalTrafficRankKey = "node:node_today_total_traffic_rank"
	// NodeOnlineUserCacheKey 节点在线用户
	NodeOnlineUserCacheKey = "node:node_online_user:%d"
	// UserOnlineIpCacheKey 用户在线IP
	UserOnlineIpCacheKey = "node:user_online_ip:%d"
	// AllNodeOnlineUserCacheKey 所有节点在线用户
	AllNodeOnlineUserCacheKey = "node:all_node_online_user"
	// NodeStatusCacheKey 节点状态
	NodeStatusCacheKey = "node:status:%d"
	// AllNodeDownloadTrafficCacheKey 所有节点下载流量
	AllNodeDownloadTrafficCacheKey = "node:all_node_download_traffic"
	// AllNodeUploadTrafficCacheKey 所有节点上传流量
	AllNodeUploadTrafficCacheKey = "node:all_node_upload_traffic"
	// YesterdayTotalTrafficRank 昨日节点总流量排行榜
	YesterdayNodeTotalTrafficRank = "node:yesterday_total_traffic_rank"
	// YesterdayUploadTrafficRank 昨日节点上传流量排行榜
	YesterdayNodeUploadTrafficRank = "node:yesterday_upload_traffic_rank"
	// YesterdayDownloadTrafficRank 昨日节点下载流量排行榜
	YesterdayNodeDownloadTrafficRank = "node:yesterday_download_traffic_rank"
	// YesterdayUserTotalTrafficRank 昨日用户总流量排行榜
	YesterdayUserTotalTrafficRank = "node:yesterday_user_total_traffic_rank"
	// YesterdayUserUploadTrafficRank 昨日用户上传流量排行榜
	YesterdayUserUploadTrafficRank = "node:yesterday_user_upload_traffic_rank"
	// YesterdayUserDownloadTrafficRank 昨日用户下载流量排行榜
	YesterdayUserDownloadTrafficRank = "node:yesterday_user_download_traffic_rank"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type NodeCacheClient

type NodeCacheClient struct {
	*redis.Client
	// contains filtered or unexported fields
}

func NewNodeCacheClient

func NewNodeCacheClient(rds *redis.Client) *NodeCacheClient

func (*NodeCacheClient) AddNodeTodayTraffic

func (c *NodeCacheClient) AddNodeTodayTraffic(ctx context.Context, nodeId int64, userTraffic []UserTraffic) error

AddNodeTodayTraffic Add node's today traffic

func (*NodeCacheClient) AddOnlineUserIP

func (c *NodeCacheClient) AddOnlineUserIP(ctx context.Context, users []NodeOnlineUser) error

AddOnlineUserIP adds user's online IP

func (*NodeCacheClient) AddUserTodayTraffic

func (c *NodeCacheClient) AddUserTodayTraffic(ctx context.Context, uid int64, upload, download int64) error

AddUserTodayTraffic Add user's today traffic

func (*NodeCacheClient) GetAllNodeDownloadTraffic

func (c *NodeCacheClient) GetAllNodeDownloadTraffic(ctx context.Context) (int64, error)

GetAllNodeDownloadTraffic Get all node download traffic

func (*NodeCacheClient) GetAllNodeOnlineUser

func (c *NodeCacheClient) GetAllNodeOnlineUser(ctx context.Context) ([]string, error)

GetAllNodeOnlineUser Get all node online user

func (*NodeCacheClient) GetAllNodeUploadTraffic

func (c *NodeCacheClient) GetAllNodeUploadTraffic(ctx context.Context) (int64, error)

GetAllNodeUploadTraffic Get all node upload traffic

func (*NodeCacheClient) GetNodeOnlineUser

func (c *NodeCacheClient) GetNodeOnlineUser(ctx context.Context, nodeId int64) (map[int64][]string, error)

GetNodeOnlineUser gets node's online users and IPs

func (*NodeCacheClient) GetNodeStatus

func (c *NodeCacheClient) GetNodeStatus(ctx context.Context, nodeId int64) (NodeStatus, error)

GetNodeStatus Get node status

func (*NodeCacheClient) GetNodeTodayDownloadTrafficRank

func (c *NodeCacheClient) GetNodeTodayDownloadTrafficRank(ctx context.Context, n int64) ([]NodeTodayTrafficRank, error)

GetNodeTodayDownloadTrafficRank Get node's today download traffic ranking top N

func (*NodeCacheClient) GetNodeTodayTotalTrafficRank

func (c *NodeCacheClient) GetNodeTodayTotalTrafficRank(ctx context.Context, n int64) ([]NodeTodayTrafficRank, error)

GetNodeTodayTotalTrafficRank Get node's today total traffic ranking top N

func (*NodeCacheClient) GetNodeTodayUploadTrafficRank

func (c *NodeCacheClient) GetNodeTodayUploadTrafficRank(ctx context.Context, n int64) ([]NodeTodayTrafficRank, error)

GetNodeTodayUploadTrafficRank Get node's today upload traffic ranking top N

func (*NodeCacheClient) GetOnlineNodeStatusCount

func (c *NodeCacheClient) GetOnlineNodeStatusCount(ctx context.Context) (int64, error)

GetOnlineNodeStatusCount Get Online Node Status Count

func (*NodeCacheClient) GetUserOnlineIp

func (c *NodeCacheClient) GetUserOnlineIp(ctx context.Context, uid int64) ([]string, error)

GetUserOnlineIp gets user's online IPs

func (*NodeCacheClient) GetUserTodayDownloadTrafficRank

func (c *NodeCacheClient) GetUserTodayDownloadTrafficRank(ctx context.Context, n int64) ([]UserTodayTrafficRank, error)

GetUserTodayDownloadTrafficRank Get user's today download traffic ranking top N

func (*NodeCacheClient) GetUserTodayTotalTrafficRank

func (c *NodeCacheClient) GetUserTodayTotalTrafficRank(ctx context.Context, n int64) ([]UserTodayTrafficRank, error)

GetUserTodayTotalTrafficRank Get user's today total traffic ranking top N

func (*NodeCacheClient) GetUserTodayUploadTrafficRank

func (c *NodeCacheClient) GetUserTodayUploadTrafficRank(ctx context.Context, n int64) ([]UserTodayTrafficRank, error)

GetUserTodayUploadTrafficRank Get user's today upload traffic ranking top N

func (*NodeCacheClient) GetYesterdayNodeTotalTrafficRank

func (c *NodeCacheClient) GetYesterdayNodeTotalTrafficRank(ctx context.Context) ([]NodeTodayTrafficRank, error)

GetYesterdayNodeTotalTrafficRank Get yesterday node total traffic rank

func (*NodeCacheClient) GetYesterdayUserTotalTrafficRank

func (c *NodeCacheClient) GetYesterdayUserTotalTrafficRank(ctx context.Context) ([]UserTodayTrafficRank, error)

GetYesterdayUserTotalTrafficRank Get yesterday user total traffic rank

func (*NodeCacheClient) ResetTodayTrafficData

func (c *NodeCacheClient) ResetTodayTrafficData(ctx context.Context) error

ResetTodayTrafficData Reset today's traffic data

func (*NodeCacheClient) UpdateNodeOnlineUser

func (c *NodeCacheClient) UpdateNodeOnlineUser(ctx context.Context, nodeId int64, users []NodeOnlineUser) error

UpdateNodeOnlineUser updates node's online users and IPs

func (*NodeCacheClient) UpdateNodeStatus

func (c *NodeCacheClient) UpdateNodeStatus(ctx context.Context, nodeId int64, status NodeStatus) error

UpdateNodeStatus Update node status

func (*NodeCacheClient) UpdateYesterdayNodeTotalTrafficRank

func (c *NodeCacheClient) UpdateYesterdayNodeTotalTrafficRank(ctx context.Context, nodes []NodeTodayTrafficRank) error

UpdateYesterdayNodeTotalTrafficRank Update yesterday node total traffic rank

func (*NodeCacheClient) UpdateYesterdayUserTotalTrafficRank

func (c *NodeCacheClient) UpdateYesterdayUserTotalTrafficRank(ctx context.Context, users []UserTodayTrafficRank) error

UpdateYesterdayUserTotalTrafficRank Update yesterday user total traffic rank

type NodeOnlineUser

type NodeOnlineUser struct {
	SID int64
	IP  string
}

type NodeStatus

type NodeStatus struct {
	Cpu       float64
	Mem       float64
	Disk      float64
	UpdatedAt int64
}

type NodeTodayTrafficRank

type NodeTodayTrafficRank struct {
	ID       int64
	Name     string
	Upload   int64
	Download int64
	Total    int64
}

type UserTodayTrafficRank

type UserTodayTrafficRank struct {
	SID      int64
	Upload   int64
	Download int64
	Total    int64
}

type UserTraffic

type UserTraffic struct {
	UID      int64
	Upload   int64
	Download int64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL