forked from xyproto/simpleredis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreator.go
36 lines (27 loc) · 836 Bytes
/
creator.go
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 simpleredis
import (
"github.com/xyproto/pinterface"
)
// For implementing pinterface.ICreator
type RedisCreator struct {
pool *ConnectionPool
dbindex int
}
func NewCreator(pool *ConnectionPool, dbindex int) *RedisCreator {
return &RedisCreator{pool, dbindex}
}
func (c *RedisCreator) SelectDatabase(dbindex int) {
c.dbindex = dbindex
}
func (c *RedisCreator) NewList(id string) (pinterface.IList, error) {
return &List{c.pool, id, c.dbindex}, nil
}
func (c *RedisCreator) NewSet(id string) (pinterface.ISet, error) {
return &Set{c.pool, id, c.dbindex}, nil
}
func (c *RedisCreator) NewHashMap(id string) (pinterface.IHashMap, error) {
return &HashMap{c.pool, id, c.dbindex}, nil
}
func (c *RedisCreator) NewKeyValue(id string) (pinterface.IKeyValue, error) {
return &KeyValue{c.pool, id, c.dbindex}, nil
}