module RSpeed::Redis
Public Instance Methods
clean()
click to toggle source
# File lib/rspeed/redis.rb, line 9 def clean RSpeed::Logger.log(self, __method__, 'Cleaning pipes and profiles.') destroy(pattern: RSpeed::Variable::PIPES_PATTERN) destroy(pattern: RSpeed::Variable::PROFILE_PATTERN) end
client()
click to toggle source
# File lib/rspeed/redis.rb, line 16 def client @client ||= ::Redis.new(db: RSpeed::Env.db, host: RSpeed::Env.host, port: RSpeed::Env.port) end
destroy(pattern:)
click to toggle source
# File lib/rspeed/redis.rb, line 20 def destroy(pattern:) RSpeed::Logger.log(self, __method__, %(Destroying pattern "#{pattern}".)) keys(pattern: pattern).each { |key| client.del(key) } end
get(key)
click to toggle source
# File lib/rspeed/redis.rb, line 26 def get(key) client.get(key) end
keys(pattern:)
click to toggle source
# File lib/rspeed/redis.rb, line 30 def keys(pattern:) cursor = 0 result = [] loop do cursor, results = client.scan(cursor, match: pattern) result += results break if cursor.to_i.zero? end result end
list(key)
click to toggle source
# File lib/rspeed/redis.rb, line 44 def list(key) client.lrange(key, 0, -1) end
profiles_content(pattern: 'rspeed:profile_*')
click to toggle source
# File lib/rspeed/redis.rb, line 48 def profiles_content(pattern: 'rspeed:profile_*') client.keys(pattern).map { |key| list(key) }.flatten end
result?()
click to toggle source
# File lib/rspeed/redis.rb, line 52 def result? keys(pattern: RSpeed::Variable.result).any? end
set(key, value)
click to toggle source
# File lib/rspeed/redis.rb, line 56 def set(key, value) client.set(key, value) end
specs_finished?()
click to toggle source
# File lib/rspeed/redis.rb, line 60 def specs_finished? (RSpeed::Redis.keys(pattern: RSpeed::Variable::PIPES_PATTERN).size == RSpeed::Env.pipes).tap do |boo| RSpeed::Logger.log(self, __method__, "Specs #{boo ? 'finished.' : 'not fineshed yet.'}") end end
specs_initiated?()
click to toggle source
# File lib/rspeed/redis.rb, line 66 def specs_initiated? RSpeed::Redis.keys(pattern: RSpeed::Variable::PIPES_PATTERN).any?.tap do |boo| RSpeed::Logger.log(self, __method__, "Specs #{boo ? 'initialized.' : 'not initialized yet.'}") end end
version_the_result()
click to toggle source
# File lib/rspeed/redis.rb, line 72 def version_the_result RSpeed::Logger.log(self, __method__, 'Versioning the result.') client.rename(RSpeed::Variable.result, RSpeed::Variable.previous_result) end