Puppet Function: redis::get
- Defined in:
-
lib/puppet/functions/redis/get.rb
- Function type:
- Ruby 4.x API
Summary
Returns the value of the key being looked up or `undef` if the key does not exist.
Overview
redis::get(String[1] $key, Redis::RedisUrl $url, Optional[String] $default) ⇒ Optional[String]
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/puppet/functions/redis/get.rb', line 6
Puppet::Functions.create_function(:'redis::get') do
dispatch :get do
param 'String[1]', :key
param 'Redis::RedisUrl', :url
optional_param 'String', :default
return_type 'Optional[String]'
end
def get(key, url, default = nil)
Redis.new(url: url).get(key) || default
rescue Redis::CannotConnectError, SocketError => e
raise Puppet::Error, "connection to redis server failed - #{e}" unless default
Puppet.debug "Connection to redis failed with #{e} - Returning default value of #{default}"
default
end
end
|