Skip to content

Instantly share code, notes, and snippets.

View xiewenwei's full-sized avatar

Vincent Xie xiewenwei

View GitHub Profile
@xiewenwei
xiewenwei / gist:23bb908ed954c8e74ef3
Created May 29, 2015 10:51
read_cache_of_redis.rb
require 'redis'
require 'redis-store'
require 'redis-activesupport'
require 'active_support'
require 'active_support/cache/dalli_store'
CACHE = ::ActiveSupport::Cache::RedisStore.new host: '192.168.1.20', db: 0, port: 6379, namespace: 'demo'
n = 10000
n.times {|i| CACHE.write "user:#{i}:counter", i * i }
@xiewenwei
xiewenwei / gist:b55070b49a73f187c284
Created May 29, 2015 09:56
read_cache_of_memcached.rb
require 'dalli'
require 'active_support'
require 'active_support/cache/dalli_store'
CACHE = ::ActiveSupport::Cache::DalliStore.new 'localhost', namespace: 'demo'
n = 10000
n.times {|i| CACHE.write "user:#{i}:counter", i * i }
def read_in_batch(total, batch_size)