Sha256: 162e501e1043745a1a2d49f2028ea0fe2ff75adefdd913d4b613d222c17bfc15

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

class ActiveOrm::Redis::Set < ActiveOrm::Redis

  def self.find(key)
    value = client.smembers(normalize_key(key))
    value = metatransform(value)
    value
  end

  def self.combine(*args)
    value = client.sunion(*args)
    value = metatransform(value)
    value
  end

  def self.difference(*args)
    value = client.sdiff(*args)
    value = metatransform(value)
    value
  end

  def self.intersection(key, *args)
    value = client.sinter(normalize_key(key), *args)
    value = metatransform(value)
    value
  end

  def self.sample(key, value=1)
    value = client.srandmember(normalize_key(key), value)
    value = metatransform(value)
    value
  end

  def self.value?(key, value)
    client.sismember(normalize_key(key), value)
  end

  def self.count(key)
    client.scard(normalize_key(key))
  end

  def self.create(key, *args)
    client.sadd(normalize_key(key), args)
  end

  def self.create_combination(key, *args)
    client.sunionstore(normalize_key(key), *args)
  end

  def self.create_difference(key, *args)
    client.sdiffstore(normalize_key(key), *args)
  end

  def self.create_intersection(key, *args)
    client.sinterstore(normalize_key(key), *args)
  end

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

  def self.destroy(key, *args)
    client.srem(normalize_key(key), *args)
  end

  def self.destroy_random(key)
    client.spop(normalize_key(key))
  end

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

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_orm-2.4.0 lib/active_orm/redis/set.rb
active_orm-2.3.0 lib/active_orm/redis/set.rb