4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/rediska/sort_method.rb', line 4
def sort(key, *redis_options_array)
return [] if !key || type(key) == 'none'
unless %w(list set zset).include? type(key)
warn "Operation against a key holding the wrong kind of value: Expected list, set or zset at #{key}."
raise Redis::CommandError.new('WRONGTYPE Operation against a key holding the wrong kind of value')
end
options = (redis_options_array)
projected = project(data[key], options[:by], options[:get])
sorted = sort_by(projected, options[:order])
sliced = slice(sorted, options[:limit])
options[:store] ? rpush(options[:store], sliced) : sliced.flatten(1)
end
|