class Corpshort::Backends::Redis

Attributes

prefix[R]

Public Class Methods

new(redis: ::Redis.method(:current), prefix: "corpshort:") click to toggle source
# File lib/corpshort/backends/redis.rb, line 10
def initialize(redis: ::Redis.method(:current), prefix: "corpshort:")
  @redis = redis
  @prefix = prefix
end

Public Instance Methods

redis() click to toggle source
# File lib/corpshort/backends/redis.rb, line 97
def redis
  Thread.current[redis_thread_key] ||= @redis.call
end

Private Instance Methods

redis_thread_key() click to toggle source
# File lib/corpshort/backends/redis.rb, line 116
def redis_thread_key
  @redis_thread_key ||= :"corpshort_backend_redis_#{self.__id__}"
end
url_key(url) click to toggle source
# File lib/corpshort/backends/redis.rb, line 103
def url_key(url)
  "#{@prefix}url:#{Digest::SHA384.hexdigest(url)}"
end