AbstractStore
# File Ruby/lib/mini_profiler/storage/memcache_store.rb, line 8 def initialize(client = nil, prefix = "MPMemcacheStore") require 'dalli' unless defined? Dalli @prefix = prefix @client = client || Dalli::Client.new(['localhost:11211']) end
# File Ruby/lib/mini_profiler/storage/memcache_store.rb, line 45 def get_unviewed_ids(user) @client.get("#{@prefix}-#{user}-v") || [] end
# File Ruby/lib/mini_profiler/storage/memcache_store.rb, line 18 def load(id) raw = @client.get("#{@prefix}#{id}") if raw Marshal::load raw end end
# File Ruby/lib/mini_profiler/storage/memcache_store.rb, line 14 def save(page_struct) @client.set("#{@prefix}#{page_struct['Id']}", Marshal::dump(page_struct), EXPIRE_SECONDS) end
# File Ruby/lib/mini_profiler/storage/memcache_store.rb, line 25 def set_unviewed(user, id) @client.add("#{@prefix}-#{user}-v", [], EXPIRE_SECONDS) MAX_RETRIES.times do break if @client.cas("#{@prefix}-#{user}-v", EXPIRE_SECONDS) do |ids| ids << id unless ids.include?(id) ids end end end
# File Ruby/lib/mini_profiler/storage/memcache_store.rb, line 35 def set_viewed(user, id) @client.add("#{@prefix}-#{user}-v", [], EXPIRE_SECONDS) MAX_RETRIES.times do break if @client.cas("#{@prefix}-#{user}-v", EXPIRE_SECONDS) do |ids| ids.delete id ids end end end
Generated with the Darkfish Rdoc Generator 2.