Sha256: c6d8382268506eb996b8f143fa700675c988b22f124705fcc798a79877a6fcee

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

# Sc4ry module
# @note namespace
module Sc4ry

  # Sc4ry:Backends module
  # @note namespace
  module Backends

    # class of the memory backend
    class Memory
              
      # Constructor
      # @param [Hash] config Config map 
      # @return [Sc4ry::Backends::Memory] a in Memory backend
      def initialize(config=nil?)
        @data = Hash::new
      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 @data.keys
      end

      # return value of queried record
      # @param key [Symbol] the name of the record
      # @return [String] content value of record
      def get(key: )
        return @data[key]
      end

      # defined and store value for specified key
      # @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(key:, value: )
        @data[key] = value
      end 

      # delete a specific record
      # @param params [Symbol] the name of the record
       # @return [Boolean] status of the operation
      def del(key: )
        @data.delete key
      end 

      # flush all records in backend
      # @return [Boolean] status of the operation
      def flush
        @data.clear
      end

      # verifiy a specific record existence
      # @param key [Symbol] the name of the record
      # @return [Boolean] presence of the record
      def exist?(key: )
        return @data.include? key
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sc4ry-0.2.0 lib/sc4ry/backends/memory.rb