-
Notifications
You must be signed in to change notification settings - Fork 256
/
Copy pathRedisClient.scala
36 lines (28 loc) · 1.19 KB
/
RedisClient.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.redis
import com.redis.operations._
/**
* Redis client
*
*/
class Redis(val host: String = "localhost", val port: Int = 6379) extends Operations
with ListOperations
with SetOperations
with NodeOperations
with KeySpaceOperations
with SortOperations
with SortedSetOperations {
// Points to the connection to a server instance
val connection = Connection(host, port)
var db: Int = 0
// Connect and Disconnect to the Redis server
def connect = connection.connect
def disconnect = connection.disconnect
def connected: Boolean = connection.connected
// Establish the connection to the server instance on initialize
connect
// Get Redis Client connection.
def getConnection(key: String) = getConnection
def getConnection = connection
// Outputs a formatted representation of the Redis server.
override def toString = connection.host+":"+connection.port+" <connected:"+connection.connected+">"
}