• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

swarthy / redis-semaphore / #395

22 Mar 2025 11:21AM UTC coverage: 99.528%. Remained the same
#395

push

swarthy
5.6.2

100 of 101 branches covered (99.01%)

Branch coverage included in aggregate %.

533 of 535 relevant lines covered (99.63%)

311.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/multiSemaphore/refresh/lua.ts
1
import { createEval } from '../../utils/index'
1✔
2

3
export const refreshLua = createEval<
1,598✔
4
  [string, number, number, string, number, number],
5
  0 | 1
6
>(
7
  `
8
  local key = KEYS[1]
9
  local limit = tonumber(ARGV[1])
10
  local permits = tonumber(ARGV[2])
11
  local identifier = ARGV[3]
12
  local lockTimeout = tonumber(ARGV[4])
13
  local now = tonumber(ARGV[5])
14
  local expiredTimestamp = now - lockTimeout
15
  local args = {}
16

17
  redis.call('zremrangebyscore', key, '-inf', expiredTimestamp)
18

19
  if redis.call('zscore', key, identifier .. '_0') then
20
    for i=0, permits - 1 do
21
      table.insert(args, now)
22
      table.insert(args, identifier .. '_' .. i)
23
    end
24
    redis.call('zadd', key, unpack(args))
25
    redis.call('pexpire', key, lockTimeout)
26
    return 1
27
  else
28
    return 0
29
  end`,
30
  1
31
)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc