Slide 11
Slide 11 text
11
SecondLevelCache `.fetch_by_index` (֦ு)
{
“user_item/fbi/user_id/101” => [10001, 10002, 10003],
“user_item/10001” => “[10001, 101, 1, …]”,
“user_item/10002” => “[10002, 101, 2, …]”,
“user_item/10003” => “[10003, 101, 3, …]”
}
select id from user_items where user_id = 101;
select * from user_items where id in (10001, 10002, 10003);
app
memcached
MySQL
UserItem.fetch_by_index(user_id:101)
class UserItem < ActiveRecord::Base
acts_as_cached(version: 1, expires_in: 1.day)
acts_as_cached_by_index(:user_id)
end
# indexΛு͍ͬͯΔΧϥϜͷΈࢦఆՄ
no cached
cached
※Ωϟογϡ͍ͯ͠ͳ͍ࠩͷΈMySQLʹ͍߹ΘͤΔ
# جຊతʹexpire͠ͳ͍
# සൟʹexpire͢Δ