Sha256: e7b481f72f58e408e6e1ce3479deae02a87ff26036b987a14b03a2c1fb92cef0

Contents?: true

Size: 604 Bytes

Versions: 2

Compression:

Stored size: 604 Bytes

Contents

module Memdash
  module Client
    def self.included(base)
      base.class_eval do
        alias_method :perform_without_stats, :perform
        alias_method :perform, :perform_with_stats
      end
    end

    def perform_with_stats(op, key, *args)
      ret = perform_without_stats(op, key, *args)
      resp = perform_without_stats(:get, 'memdash')
      if resp.nil? || resp == 'Not found'
        generate_stats
        perform_without_stats(:add, 'memdash', true, Memdash.ttl, nil)
      end
      ret
    end

    private

    def generate_stats
      raise NotImplementedError
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
memdash-0.1.0 lib/memdash/client.rb
memdash-0.0.1 lib/memdash/client.rb