]> git.saurik.com Git - redis.git/blob - client-libraries/scala/src/main/scala/com/redis/Operations/SortOperations.scala
f3d0ca14d6499075b02247daadd91a485f3cd1e7
[redis.git] / client-libraries / scala / src / main / scala / com / redis / Operations / SortOperations.scala
1 package com.redis.operations
2
3 /**
4 * Redis sort operations
5 *
6 */
7
8 trait SortOperations{
9
10 def getConnection(key: String): Connection
11
12 // SORT
13 // Sort a Set or a List accordingly to the specified parameters.
14 def sort(args: Any): List[String] = args match {
15 case (key: String, command: String) => doSort(key, command)
16 case (key: String) => doSort(key, "")
17 }
18
19 def doSort(key: String, command: String): List[String] = {
20 val connection = getConnection(key)
21 if(command != "") {
22 connection.write("SORT "+key+" "+command+"\r\n")
23 } else {
24 connection.write("SORT "+key+"\r\n")
25 }
26 connection.readList
27 }
28 }