lib/sc4ry/backends/redis.rb in sc4ry-0.1.8 vs lib/sc4ry/backends/redis.rb in sc4ry-0.2.0
- old
+ new
@@ -14,49 +14,50 @@
end
# return the list of find records in backend for a specific pattern
# @return [Array] list of record (for all hostname if hostname is specified)
def list
- return @store.keys('*')
+ return @be.keys('*').map(&:to_sym)
end
# return value of queried record
- # @param [Hash] options
- # @option options [Symbol] :key the name of the record
+ # @param key [Symbol] the name of the record
# @return [String] content value of record
- def get(options)
- return @store.get(options[:key])
+ def get(key:)
+ res = YAML.load(@be.get(key))
+ res[:exceptions].map! {|item| item = Object.const_get(item) if item.class == String }
+ return res
end
# defined and store value for specified key
- # @param [Hash] options
- # @option options [Symbol] :key the name of the record
- # @option options [Symbol] :value the content value of the record
+ # @param key [Symbol] :key the name of the record
+ # @param value [Symbol] :value the content value of the record
# @return [String] content value of record
- def put(options)
- @store.set options[:key], options[:value]
+ def put(key: ,value:)
+ data = value.dup
+ data[:exceptions].map! {|item| item = item.name.to_s if item.class == Class }
+ @be.set key, data.to_yaml
end
# delete a specific record
- # @param [Hash] options
- # @option options [Symbol] :key the name of the record
+ # @param key [Symbol] the name of the record
# @return [Boolean] status of the operation
- def del(options)
- @store.del options[:key]
+ def del(key: )
+ @be.del key
end
# flush all records in backend
+ # @return [Boolean] status of the operation
def flush
- @store.flushdb
+ @be.flushdb
end
- # verifiy a specific record existance
- # @param [Hash] options
- # @option options [Symbol] :key the name of the record
+ # verifiy a specific record existence
+ # @param key [Symbol] the name of the record
# @return [Boolean] presence of the record
- def exist?(options)
- return ( not @store.get(options[:key]).nil?)
+ def exist?(key: )
+ return ( not @be.get(key).nil?)
end
end
\ No newline at end of file