Sha256: cb2d221b8ae8d1186101c808ce068695de23a2c8a3858d0e011d58f9cddce08e

Contents?: true

Size: 1.83 KB

Versions: 4

Compression:

Stored size: 1.83 KB

Contents

class ActiveOrm::Redis::Key < ActiveOrm::Redis

  def self.exists?(key)
    client.exists(normalize_key(key))
  end

  def self.type?(key)
    client.type(normalize_key(key))
  end

  def self.ttl?(key, format = :seconds)
    normalized_key = normalize_key(key)

    seconds?(format) ? client.ttl(normalized_key) : client.pttl(normalized_key)
  end

  def self.sort(key, opts = {})
    client.sort(normalize_key(key), opts)
  end

  def self.sample
    client.randomkey
  end

  def self.rename(key, value)
    client.rename(normalize_key(key), value.to_s)
  end

  def self.rename!(key, value)
    client.renamenx(normalize_key(key), value.to_s)
  end

  def self.destroy(key)
    client.del(normalize_key(key))
  end

  def self.persist(key)
    client.persist(normalize_key(key))
  end

  def self.expire(key, seconds, format = :seconds)
    normalized_key = normalize_key(key)

    if seconds?(format)
      client.expire(normalized_key, seconds)
    else
      client.pexpire(normalized_key, seconds)
    end
  end

  def self.expire_at(key, seconds, format = :seconds)
    normalized_key = normalize_key(key)

    if seconds?(format)
      client.expireat(normalized_key, seconds)
    else
      client.pexpireat(normalized_key, seconds)
    end
  end

  def self.dump(key)
    client.dump(normalize_key(key))
  end

  def self.match(pattern = '*')
    value = client.keys(normalize_key(pattern))
    value = nil if value.empty?
    value
  end

  def self.migrate(key, options)
    client.migrate(normalize_key(key), options)
  end

  def self.move(key, destination)
    client.move(normalize_key(key), destination)
  end

  def self.object(*args)
    client.object(args)
  end

  def self.restore(key, milliseconds, value)
    client.restore(normalize_key(key), milliseconds, value)
  end

  def self.scan(cursor, opts = {})
    client.scan(cursor, opts)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active_orm-4.0.3 lib/active_orm/redis/key.rb
active_orm-4.0.2 lib/active_orm/redis/key.rb
active_orm-4.0.1 lib/active_orm/redis/key.rb
active_orm-4.0.0 lib/active_orm/redis/key.rb