summaryrefslogtreecommitdiffhomepage
path: root/benchmarks/workloads/ruby_template/main.rb
blob: 35c2393778424f75b48c2e9de9b8f54afc726a03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require "sinatra"
require "securerandom"
require "redis"

redis_host = ENV["host"]
$redis = Redis.new(host: redis_host)

def generateText
    for i in 0..99
        $redis.set(i, randomBody(1024))
    end
end

def randomBody(length)
    return SecureRandom.alphanumeric(length)
end

generateText
template = ERB.new(File.read('./index.erb'))

get "/" do
    texts = Array.new
    for i in 0..4
        texts.push($redis.get(rand(0..99)))
    end
    template.result_with_hash(text: texts)
end