Last active
May 21, 2020 15:29
-
-
Save ritikesh/aae1cc94912501f63bfb7a67517ce2a2 to your computer and use it in GitHub Desktop.
blog gists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Memcache | |
KEY_HASH = YAML.load_file(File.join(Rails.root, 'config', 'memcached_keys.yml')).symbolize_keys! | |
def self.key(key, value) | |
“#{KEY_HASH[key]}:#{value}” | |
end | |
def self.multi_key(key, value1, value2) | |
“#{KEY_HASH[key]}:#{value1}:#{value2}” | |
end | |
end | |
Memcache::TENANT_BY_ID = "TENANT_BY_ID:%{tenant_id}" | |
Benchmark.bmbm { |x| | |
x.report(‘existing’) { | |
1000.times do |n| | |
1000.times { | |
Memcache::TENANT_BY_ID % { tenant_id: n } | |
} | |
end | |
} | |
x.report(‘new’) { | |
1000.times do |n| | |
1000.times { | |
Memcache.key(:tenant_by_id, n) | |
} | |
end | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment