cartodb-4.42/services/data-repository/backend/redis/set.rb
2024-04-06 05:25:13 +00:00

33 lines
720 B
Ruby

require 'redis'
module DataRepository
module Backend
class Redis
class Set
def initialize(redis=Redis.new)
@redis = redis
end #initialize
def store(key, data)
workaround_until_resque_supports_latest_redis_gem(key, data)
end #store
def fetch(key)
redis.smembers key
end #fetch
private
attr_reader :redis
def workaround_until_resque_supports_latest_redis_gem(key, data)
redis.multi do
data.to_a.each { |item| redis.sadd(key, item) }
end
end #workaround_until_resque_supports_latest_redis_gem
end # Set
end # Redis
end # Backend
end # DataRepository