Sha256: b564a173178b669f63550757614569ad7b48b75e57bd513b2f3c1af47615705c

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 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 move(dbindex)
        redis.move key, dbindex
      end
      
      # See the documentation for SORT: http://code.google.com/p/redis/wiki/SortCommand
      # TODO
      # def sort(options)
      #   args = []
      #   args += ['sort']
      #   from_redis redis.sort key
      # end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
redis-objects-0.5.0 lib/redis/helpers/core_commands.rb
redis-objects-0.4.1 lib/redis/helpers/core_commands.rb
redis-objects-0.4.0 lib/redis/helpers/core_commands.rb
redis-objects-0.3.2 lib/redis/helpers/core_commands.rb
redis-objects-0.3.1 lib/redis/helpers/core_commands.rb
redis-objects-0.3.0 lib/redis/helpers/core_commands.rb
redis-objects-0.2.4 lib/redis/helpers/core_commands.rb