onlinecache

package
v1.21.4 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package onlinecache shares the lease update used by global device counts and per-server online reports.

Index

Constants

This section is empty.

Variables

View Source
var RenewScript = redis.NewScript(`
redis.replicate_commands()
local now = tonumber(redis.call('TIME')[1])
local ttl = tonumber(ARGV[1])
local expires = now + ttl
redis.call('ZREMRANGEBYSCORE', KEYS[1], '-inf', now)
for i = 2, #ARGV do
  local previous = tonumber(redis.call('ZSCORE', KEYS[1], ARGV[i])) or 0
  if previous < expires then
    redis.call('ZADD', KEYS[1], expires, ARGV[i])
  end
end
redis.call('EXPIRE', KEYS[1], ttl)
return 1
`)

RenewScript accepts a TTL in seconds followed by the members to renew. Compare scores in Lua rather than ZADD GT to retain Redis 6.0 support. Use Eval when queuing this in a pipeline: Run cannot retry NOSCRIPT after Exec.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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