Class: Certmeister::Redis::Store

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/certmeister/redis/store.rb

Instance Method Summary collapse

Constructor Details

#initialize(redis, environment = "development") ⇒ Store

Returns a new instance of Store.



9
10
11
12
13
# File 'lib/certmeister/redis/store.rb', line 9

def initialize(redis, environment = "development")
  @redis = redis
  @environment = environment
  @healthy = true
end

Instance Method Details

#eachObject



28
29
30
31
32
33
# File 'lib/certmeister/redis/store.rb', line 28

def each
  @redis.scan_each do |key|
    cn = cn_from_pem_key(key)
    yield cn, fetch(cn)
  end
end

#fetch(cn) ⇒ Object



19
20
21
# File 'lib/certmeister/redis/store.rb', line 19

def fetch(cn)
  @redis.get(pem_key(cn))
end

#health_checkObject



35
36
37
# File 'lib/certmeister/redis/store.rb', line 35

def health_check
  @healthy
end

#remove(cn) ⇒ Object



23
24
25
26
# File 'lib/certmeister/redis/store.rb', line 23

def remove(cn)
  num_removed = @redis.del(pem_key(cn))
  num_removed == 1
end

#store(cn, pem) ⇒ Object



15
16
17
# File 'lib/certmeister/redis/store.rb', line 15

def store(cn, pem)
  @redis.set(pem_key(cn), pem)
end