Created
January 20, 2016 15:09
-
-
Save HenleyChiu/25d7c9a6b854cafc7f0e to your computer and use it in GitHub Desktop.
save and get a large JSON string to redis
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
require "benchmark" | |
url = 'https://s3.amazonaws.com/buzzsumo-exports/test.json' | |
source = open(url).read | |
puts "# of bytes: #{source.size}" | |
redis = Redis.new(:host => "localhost", :port => 6379, :db => 0) | |
time = Benchmark.measure do | |
redis.set("cache_key", source) | |
end | |
puts "Time to save to redis: #{time}" | |
str = "" | |
time = Benchmark.measure do | |
str = redis.get("cache_key") | |
end | |
puts "Time to get from redis: #{time}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment