Module: CableX::Cable::RateLimit::RateLimitRedis

Included in:
Connection
Defined in:
lib/cable_x/cable/rate_limit/rate_limit_redis.rb

Overview

Process Rate Limit

Instance Method Summary collapse

Instance Method Details

#block_device_key(schedule) ⇒ Object



29
30
31
# File 'lib/cable_x/cable/rate_limit/rate_limit_redis.rb', line 29

def block_device_key(schedule)
  "#{redis_config[:channel_prefix]}-rl-block-#{schedule}-#{device_id}"
end

#device_key(schedule) ⇒ Object



25
26
27
# File 'lib/cable_x/cable/rate_limit/rate_limit_redis.rb', line 25

def device_key(schedule)
  "#{redis_config[:channel_prefix]}-rl-#{schedule}-#{device_id}"
end

#redis_exists(key) ⇒ Object



17
18
19
# File 'lib/cable_x/cable/rate_limit/rate_limit_redis.rb', line 17

def redis_exists(key)
  redis.exists? key
end

#redis_get(key) ⇒ Object



21
22
23
# File 'lib/cable_x/cable/rate_limit/rate_limit_redis.rb', line 21

def redis_get(key)
  redis.get key
end

#redis_incr(key) ⇒ Object



13
14
15
# File 'lib/cable_x/cable/rate_limit/rate_limit_redis.rb', line 13

def redis_incr(key)
  redis.incr key
end

#redis_set(key, value, expire_millisecond) ⇒ Object



9
10
11
# File 'lib/cable_x/cable/rate_limit/rate_limit_redis.rb', line 9

def redis_set(key, value, expire_millisecond)
  redis.set key, value, px: expire_millisecond
end