forked from acrosa/scala-redis
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #243 from atais/api-cleanup
Common interface for single redis client and cluster classes
- Loading branch information
Showing
57 changed files
with
2,012 additions
and
1,730 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
package com.redis | ||
|
||
import serialization._ | ||
import com.redis.api.EvalApi | ||
import com.redis.serialization._ | ||
|
||
trait EvalOperations { self: Redis => | ||
trait EvalOperations extends EvalApi { | ||
self: Redis => | ||
|
||
// EVAL | ||
// evaluates lua code on the server. | ||
def evalMultiBulk[A](luaCode: String, keys: List[Any], args: List[Any])(implicit format: Format, parse: Parse[A]): Option[List[Option[A]]] = | ||
send("EVAL", argsForEval(luaCode, keys, args))(asList[A]) | ||
override def evalMultiBulk[A](luaCode: String, keys: List[Any], args: List[Any])(implicit format: Format, parse: Parse[A]): Option[List[Option[A]]] = | ||
send("EVAL", argsForEval(luaCode, keys, args))(asList[A]) | ||
|
||
def evalBulk[A](luaCode: String, keys: List[Any], args: List[Any])(implicit format: Format, parse: Parse[A]): Option[A] = | ||
override def evalBulk[A](luaCode: String, keys: List[Any], args: List[Any])(implicit format: Format, parse: Parse[A]): Option[A] = | ||
send("EVAL", argsForEval(luaCode, keys, args))(asBulk) | ||
def evalInt(luaCode: String, keys: List[Any], args: List[Any]): Option[Int] = | ||
|
||
override def evalInt(luaCode: String, keys: List[Any], args: List[Any]): Option[Int] = | ||
send("EVAL", argsForEval(luaCode, keys, args))(asInt) | ||
def evalMultiSHA[A](shahash: String, keys: List[Any], args: List[Any])(implicit format: Format, parse: Parse[A]): Option[List[Option[A]]] = | ||
|
||
override def evalMultiSHA[A](shahash: String, keys: List[Any], args: List[Any])(implicit format: Format, parse: Parse[A]): Option[List[Option[A]]] = | ||
send("EVALSHA", argsForEval(shahash, keys, args))(asList[A]) | ||
def evalSHA[A](shahash: String, keys: List[Any], args: List[Any])(implicit format: Format, parse: Parse[A]): Option[A] = | ||
|
||
override def evalSHA[A](shahash: String, keys: List[Any], args: List[Any])(implicit format: Format, parse: Parse[A]): Option[A] = | ||
send("EVALSHA", argsForEval(shahash, keys, args))(asAny.asInstanceOf[Option[A]]) | ||
|
||
def evalSHABulk[A](shahash: String, keys: List[Any], args: List[Any])(implicit format: Format, parse: Parse[A]): Option[A] = | ||
override def evalSHABulk[A](shahash: String, keys: List[Any], args: List[Any])(implicit format: Format, parse: Parse[A]): Option[A] = | ||
send("EVALSHA", argsForEval(shahash, keys, args))(asBulk) | ||
def scriptLoad(luaCode: String): Option[String] = { | ||
|
||
override def scriptLoad(luaCode: String): Option[String] = { | ||
send("SCRIPT", List("LOAD", luaCode))(asBulk) | ||
} | ||
def scriptExists(shahash: String): Option[Int] = { | ||
|
||
override def scriptExists(shahash: String): Option[Int] = { | ||
send("SCRIPT", List("EXISTS", shahash))(asList[String]) match { | ||
case Some(list) => { | ||
if (list.size>0 && list(0).isDefined){ | ||
if (list.size > 0 && list(0).isDefined) { | ||
Some(list(0).get.toInt) | ||
}else{ | ||
} else { | ||
None | ||
} | ||
} | ||
case None => None | ||
} | ||
} | ||
def scriptFlush: Option[String] = { | ||
|
||
override def scriptFlush: Option[String] = { | ||
send("SCRIPT", List("FLUSH"))(asString) | ||
} | ||
|
||
private def argsForEval(luaCode: String, keys: List[Any], args: List[Any]): List[Any] = | ||
luaCode :: keys.length :: keys ::: args | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.