Sha256: eac06e0b63645b01299468bcf02aec0f715176ebd138fc27a1c7ab70eea6c6be

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

class Redis
  module Helpers
    # These are core commands that all types share (rename, etc)
    module CoreCommands
      def exists?
        redis.exists key
      end
      
      def delete
        redis.del key
      end
      alias_method :del, :delete
      alias_method :clear, :delete
      
      def type
        redis.type key
      end

      def rename(name, setkey=true)
        dest = name.is_a?(self.class) ? name.key : name
        ret  = redis.rename key, dest
        @key = dest if ret && setkey
        ret
      end

      def renamenx(name, setkey=true)
        dest = name.is_a?(self.class) ? name.key : name
        ret  = redis.renamenx key, dest
        @key = dest if ret && setkey
        ret
      end
    
      def expire(seconds)
        redis.expire key, seconds
      end

      def expireat(unixtime)
        redis.expire key, unixtime
      end

      def ttl
        redis.ttl(@key).seconds
      end

      def move(dbindex)
        redis.move key, dbindex
      end

      def sort(options={})
        options[:order] ||= "asc alpha"
        redis.sort(key, options)
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redis-objects-0.5.2 lib/redis/helpers/core_commands.rb