class ActiveOrm::Redis::SortedSet < ActiveOrm::Redis def self.find(key, position, opts = {}) position -= 1 value = client.zrange(normalize_key(key), position, position, opts) value = value.first value = metamorph(value) if evaluate? value end def self.find_score(key, position, opts = {}) value = client.zrangebyscore(normalize_key(key), position, position, opts) value = value.first value = metamorph(value) if evaluate? value end def self.first(key, opts = {}) value = client.zrange(normalize_key(key), 0, 0, opts) value = value.first value = metamorph(value) if evaluate? value end def self.first_score(key, opts = {}) value = client.zrangebyscore(normalize_key(key), 1, 1, opts) value = value.first value = metamorph(value) if evaluate? value end def self.last(key, opts = {}) value = client.zrevrange(normalize_key(key), 0, 0, opts) value = value.first value = metamorph(value) if evaluate? value end def self.last_score(key, opts = {}) value = client.zrevrangebyscore(normalize_key(key), 1, 1, opts) value = value.first value = metamorph(value) if evaluate? value end def self.between(key, start, finish, opts = {}) value = client.zrange(normalize_key(key), (start - 1), (finish - 1), opts) value = metatransform(value) value end def self.between_reverse(key, start, finish, opts = {}) value = client.zrevrange(normalize_key(key), (start - 1), (finish - 1), opts) value = metatransform(value) value end def self.between_scores(key, min, max, opts = {}) value = client.zrangebyscore(normalize_key(key), min, max, opts) value = metatransform(value) value end def self.between_scores_reverse(key, min, max, opts = {}) value = client.zrevrangebyscore(normalize_key(key), min, max, opts) value = metatransform(value) value end def self.between_lex(key, min, max, opts = {}) value = client.zrangebylex(normalize_key(key), min, max, opts) value = metatransform(value) value end def self.between_lex_reverse(key, min, max, opts = {}) value = client.zrevrangebylex(normalize_key(key), min, max, opts) value = metatransform(value) value end def self.all(key, opts = {}) value = client.zrange(normalize_key(key), '-inf', '+inf', opts) value = metatransform(value) value end def self.position(key, value) value = client.zrank(normalize_key(key), value) value += 1 unless value.nil? value end def self.position_reverse(key, value) value = client.zrevrank(normalize_key(key), value) value += 1 unless value.nil? value end def self.score(key, value) client.zscore(normalize_key(key), value) end def self.count(key) client.zcard(normalize_key(key)) end def self.count_between(key, min, max) client.zcount(normalize_key(key), min, max) end def self.create(key, *args) client.zadd(normalize_key(key), args) end def self.create_intersection(key, keys, opts = {}) client.zinterstore(normalize_key(key), keys, opts) end def self.create_combination(key, keys, opts = {}) client.zunionstore(normalize_key(key), keys, opts) end def self.increment(key, value, count) client.zincrby(normalize_key(key), count, value) end def self.destroy(key, at) client.zrem(normalize_key(key), at) end def self.destroy_between(key, start, finish) client.zremrangebyrank(normalize_key(key), (start - 1), (finish - 1)) end def self.destroy_scores(key, min, max) client.zremrangebyscore(normalize_key(key), min, max) end def self.destroy_lex(key, min, max, opts = {}) client.zrevrangebylex(normalize_key(key), max, min, opts) end def self.scan(key, cursor, opts = {}) client.zscan(normalize_key(key), cursor, opts) end end