Sha256: 73815714f4bbce10f98cf38c8e558f4203a4a220a6e0ab49a9700d08afc92a43

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 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.expireat key, unixtime
      end

      def persist
        redis.persist key
      end

      def ttl
        redis.ttl(@key)
      end

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

      def sort(options={})
        options[:order] = "asc alpha" if options.keys.count == 0  # compat with Ruby
        redis.sort(key, options)
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redis-objects-0.8.0 lib/redis/helpers/core_commands.rb
redis-objects-0.7.0 lib/redis/helpers/core_commands.rb