Sha256: 0e81167b3d3bc2c0fbb098dcf5bc6e727f94d298df47dbefb1a78e2d170a4efc

Contents?: true

Size: 586 Bytes

Versions: 2

Compression:

Stored size: 586 Bytes

Contents

module Wamp
  module Worker

    class Ticker
      attr_reader :redis, :ticker_key

      # Constructor
      #
      # @param name [Symbol] - The name of the worker
      def initialize(name)
        @redis = Wamp::Worker.config.redis(name)
        @ticker_key = "wamp:#{name}:tick"
      end

      # Returns the tick for the worker
      #
      # @return [Int] - The value of the tick
      def get
        self.redis.get(self.ticker_key) || 0
      end

      # Increments the tick
      #
      def increment
        self.redis.incr(self.ticker_key)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wamp-worker-0.1.1 lib/wamp/worker/ticker.rb
wamp-worker-0.1.0 lib/wamp/worker/ticker.rb