Sha256: 1d3374394474d6b4eaa3f5f6e3afa5fd5dae0b461623c86bdb5b8488e058f8ca
Contents?: true
Size: 807 Bytes
Versions: 2
Compression:
Stored size: 807 Bytes
Contents
module RProxy class CheckSnapshotService def initialize(redis, config) @redis = redis @snapshot_expire_in = 15 * 60 @usage_threshold = config.usage_threshold @cb_url = config.callback_url @logger = config.logger end def call(user, pass, result) s_key = "proxy:#{user}-#{pass}:snapshot" snapshot_value = @redis.get(s_key) if snapshot_value.nil? || snapshot_value.empty? @redis.setex(s_key, @snapshot_expire_in, result) else tmp = snapshot_value.to_i - result.to_i if tmp >= @usage_threshold connection = RProxy::CallbackService.call(@cb_url, user, pass, tmp) connection.assign_logger(@logger) @redis.setex(s_key, @snapshot_expire_in, result) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
r_proxy-0.1.1 | lib/r_proxy/check_snapshot_service.rb |
r_proxy-0.1.0 | lib/r_proxy/check_snapshot_service.rb |