File: creator.go

package info (click to toggle)
golang-github-xyproto-simpleredis 2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 100 kB
  • sloc: makefile: 6
file content (36 lines) | stat: -rw-r--r-- 836 bytes parent folder | download | duplicates (3)
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
}