Class: Splash::Backends::Redis
- Inherits:
-
Object
- Object
- Splash::Backends::Redis
- Includes:
- Config
- Defined in:
- lib/splash/backends/redis.rb
Overview
Redis backend definition
Constant Summary
Constants included from Constants
Constants::AUTHOR, Constants::BACKENDS_STRUCT, Constants::CONFIG_FILE, Constants::COPYRIGHT, Constants::DAEMON_LOGMON_SCHEDULING, Constants::DAEMON_METRICS_SCHEDULING, Constants::DAEMON_PID_FILE, Constants::DAEMON_PROCESS_NAME, Constants::DAEMON_PROCMON_SCHEDULING, Constants::DAEMON_STDERR_TRACE, Constants::DAEMON_STDOUT_TRACE, Constants::DEFAULT_RETENTION, Constants::EMAIL, Constants::EXECUTION_TEMPLATE, Constants::EXECUTION_TEMPLATE_TOKENS_LIST, Constants::LICENSE, Constants::LOGGERS_STRUCT, Constants::PID_PATH, Constants::PROMETHEUS_ALERTMANAGER_URL, Constants::PROMETHEUS_PUSHGATEWAY_URL, Constants::PROMETHEUS_URL, Constants::TRACE_PATH, Constants::TRANSPORTS_STRUCT, Constants::VERSION, Constants::WEBADMIN_IP, Constants::WEBADMIN_PID_FILE, Constants::WEBADMIN_PID_PATH, Constants::WEBADMIN_PORT, Constants::WEBADMIN_PROCESS_NAME, Constants::WEBADMIN_PROXY, Constants::WEBADMIN_STDERR_TRACE, Constants::WEBADMIN_STDOUT_TRACE
Instance Method Summary collapse
-
#del(options) ⇒ Boolean
delete a specific record.
-
#exist?(options) ⇒ Boolean
verifiy a specific record existance.
-
#flush ⇒ Object
flush all records in backend.
-
#get(options) ⇒ String
return value of queried record.
-
#initialize(store) ⇒ Splash::Backends::Redis
constructor
Constructor.
-
#list(pattern = '*', hostname = @hostname) ⇒ Array
return the list of find records in backend for a specific pattern.
-
#listall(pattern = '*') ⇒ Array
return the list of find records in backend for a specific pattern, without hostname Checking Redis Backend specific method.
-
#put(options) ⇒ String
defined and store value for specified key.
Methods included from Config
Methods included from ConfigUtilities
#addservice, #checkconfig, #flush_backend, #setupsplash
Methods included from Helpers
#check_unicode_term, #daemonize, #format_by_extensions, #format_response, #get_processes, #group_root, #install_file, #is_root?, #make_folder, #make_link, #run_as_root, #search_file_in_gem, #user_root, #verify_file, #verify_folder, #verify_link, #verify_service
Constructor Details
#initialize(store) ⇒ Splash::Backends::Redis
Constructor
16 17 18 19 20 21 22 23 24 |
# File 'lib/splash/backends/redis.rb', line 16 def initialize(store) @hostname = Socket.gethostname @config = get_config[:backends][:stores][store] conf = { :host => @config[:host], :port => @config[:port], :db => @config[:base].to_i} conf[:password] = @config[:auth] if @config[:auth] @store = ::Redis.new conf #@redis_cli_cmd = `which redis-cli` @store.auth(@config[:auth]) if @config[:auth] end |
Instance Method Details
#del(options) ⇒ Boolean
delete a specific record
65 66 67 68 |
# File 'lib/splash/backends/redis.rb', line 65 def del() hostname = ([:hostname])? [:hostname] : @hostname @store.del prefix_hostname([:key],hostname) end |
#exist?(options) ⇒ Boolean
verifiy a specific record existance
80 81 82 83 |
# File 'lib/splash/backends/redis.rb', line 80 def exist?() hostname = ([:hostname])? [:hostname] : @hostname return ( not @store.get(prefix_hostname([:key],hostname)).nil?) end |
#flush ⇒ Object
flush all records in backend
71 72 73 74 |
# File 'lib/splash/backends/redis.rb', line 71 def flush #`#{@redis_cli_cmd} -n #{@config[:base]} flushdb` @store.flushdb end |
#get(options) ⇒ String
return value of queried record
46 47 48 49 |
# File 'lib/splash/backends/redis.rb', line 46 def get() hostname = ([:hostname])? [:hostname] : @hostname return @store.get(prefix_hostname([:key],hostname)) end |
#list(pattern = '*', hostname = @hostname) ⇒ Array
return the list of find records in backend for a specific pattern
30 31 32 |
# File 'lib/splash/backends/redis.rb', line 30 def list(pattern='*', hostname = @hostname) return @store.keys("#{hostname}##{pattern}").map{|item| item = remove_hostname(item)} end |
#listall(pattern = '*') ⇒ Array
return the list of find records in backend for a specific pattern, without hostname Checking Redis Backend specific method
38 39 40 |
# File 'lib/splash/backends/redis.rb', line 38 def listall(pattern='*') return @store.keys(pattern) end |
#put(options) ⇒ String
defined and store value for specified key
56 57 58 59 |
# File 'lib/splash/backends/redis.rb', line 56 def put() hostname = ([:hostname])? [:hostname] : @hostname @store.set prefix_hostname([:key],hostname), [:value] end |