push
travis-ci
53 of 53 new or added lines in 11 files covered. (100.0%)
575 of 584 relevant lines covered (98.46%)
99.96 hits per line
1 |
# frozen_string_literal: true
|
|
2 |
|
|
3 |
require "json"
|
1✔ |
4 |
|
|
5 |
module Ayashige |
1✔ |
6 |
DEFAULT_TTL = 60 * 60 * 24 |
1✔ |
7 |
|
|
8 |
class Store |
1✔ |
9 |
def initialize |
1✔ |
10 |
@client = Redis.client |
27✔ |
11 |
end
|
|
12 |
|
|
13 |
def store(key, field, value) |
1✔ |
14 |
@client.multi do |
5✔ |
15 |
@client.hset key, field, value
|
5✔ |
16 |
@client.expire key, DEFAULT_TTL |
5✔ |
17 |
end
|
|
18 |
end
|
|
19 |
|
|
20 |
def exists?(key) |
1✔ |
21 |
@client.exists key
|
2✔ |
22 |
end
|
|
23 |
|
|
24 |
def get(key) |
1✔ |
25 |
@client.hgetall key
|
3✔ |
26 |
end
|
|
27 |
|
|
28 |
def keys |
1✔ |
29 |
@client.keys
|
2✔ |
30 |
end
|
|
31 |
|
|
32 |
def all |
1✔ |
33 |
keys.map { |key| [key, get(key)] }.to_h |
3✔ |
34 |
end
|
|
35 |
|
|
36 |
def self.all |
1✔ |
37 |
new.all |
× |
38 |
end
|
|
39 |
end
|
|
40 |
end
|