16. シゴトでココロオドル
• noeviction
– don't expire at all, just return an error on write operations
– デフォルト。キャッシュとして使わない場合
• volatile-lru
– remove the key with an expire set using an LRU algorithm
– キャッシュとデータ永続化を両方使いたい場合
• allkeys-lru
– remove any key according to the LRU algorithm
– 冪乗則のアクセスパターンの場合
– まよったらこれ
• volatile-random
– remove a random key with an expire set
– キャッシュとデータ永続化を両方使いたい場合
• allkeys-random
– remove a random key, any key
– 均等にアクセスがある場合
• volatile-ttl
– remove the key with the nearest expire time (minor TTL)
– キャッシュ生成時によいTTLを設定できるならこれ
• EXPIRE使うとメモリを余計にとる
• キャッシュとデータ永続化は別々のRedisインスタンスにするのがオススメ
maxmemoryに達した場合の挙動
http://redis.io/topics/lru-cache
24. シゴトでココロオドル
redis-rails で使えないコマンドが使える
コマンドがそのままメソッド名になっている
# Remove the last element in a list, append it to another list and return it.
#
# @param [String] source source key
# @param [String] destination destination key
# @return [nil, String] the element, or nil when the source key does not exist
def rpoplpush(source, destination)
synchronize do |client|
client.call([:rpoplpush, source, destination])
end
end
redis gem