Sha256: 91a836be1f2779aea4b826754dd19b4903671c315fa8bc9896b06df53436a180

Contents?: true

Size: 774 Bytes

Versions: 1

Compression:

Stored size: 774 Bytes

Contents

module Hari
  module Keys
    class Key

      attr_reader :node, :name

      def initialize(node = nil)
        @node = node
      end

      def key
        @key ||= begin
          prefix = node ? "#{Hari.node_key(node)}:" : ''
          prefix + name.to_s
        end
      end

      def delete!
        Hari.redis.del key
      end

      def exists?
        Hari.redis.exists key
      end

      def expire(milliseconds)
        Hari.redis.pexpire key, milliseconds
      end

      def expire_at(timestamp)
        Hari.redis.expireat key, ::Time.parse(timestamp).to_s
      end

      def persist
        Hari.redis.persist key
      end

      def type
        Hari.redis.type key
      end

      def ttl
        Hari.redis.ttl key
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hari-0.0.4 lib/hari/keys/key.rb