File tree Expand file tree Collapse file tree 6 files changed +105
-13
lines changed Expand file tree Collapse file tree 6 files changed +105
-13
lines changed Original file line number Diff line number Diff line change
1
+ RM ?= rm -rf
2
+ GOBUILD = go build
3
+ GOTEST = go test # -v
4
+
5
+ VARS =vars.mk
6
+ $(shell ./build_config ${VARS})
7
+ include ${VARS}
8
+
9
+ .PHONY : test clean build
10
+
11
+ build :
12
+ @cd bin/ && ${GOBUILD} Main && cd ..
13
+
14
+ test :
15
+ @cd src/FreqCtrl/ && ${GOTEST} && cd ../..
16
+
17
+ bench :
18
+ @cd src/FreqCtrl/ && ${GOTEST} -bench=. && cd ../..
19
+
20
+ clean :
21
+ ${RM} ${VARS} bin/*
Original file line number Diff line number Diff line change
1
+ package MyStruct
2
+
3
+ type Conn struct {
4
+ c int
5
+ a int
6
+ CC int
7
+ AA int
8
+ }
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ OUTPUT=$1
4
+ PWD=$( pwd)
5
+
6
+ if test -z " ${OUTPUT} " ; then
7
+ echo " Usage: $0 <output_file>"
8
+ exit 1
9
+ fi
10
+
11
+ rm -f ${OUTPUT}
12
+ touch ${OUTPUT}
13
+
14
+ if [ ! -d " bin" ]; then
15
+ $( mkdir bin)
16
+ fi
17
+
18
+ echo " GOPATH=${GOPATH} :${PWD} " >> ${OUTPUT}
Original file line number Diff line number Diff line change
1
+ GOPATH =/usr/local/godown:/home/yang/Work/GolangCode/FreqCtrl
Original file line number Diff line number Diff line change
1
+ package redistest
2
+
3
+ import (
4
+ "github.com/garyburd/redigo/redis"
5
+ )
6
+
7
+ //var conn redis.Conn
8
+ func newPool () * redis.Pool {
9
+ return & redis.Pool {
10
+ MaxIdle : 80 ,
11
+ MaxActive : 200 ,
12
+ Dial : func () (redis.Conn , error ) {
13
+ c , err := redis .Dial ("tcp" , "localhost:6379" )
14
+ if err != nil {
15
+ panic (err .Error ())
16
+ }
17
+ return c , err
18
+ },
19
+ }
20
+ }
21
+
22
+ var pool = newPool ()
23
+
24
+ /*
25
+ func Init()error{
26
+ pool = newPool()
27
+ }
28
+ */
29
+
30
+ func getConn () redis.Pool {
31
+ c := pool .Get ()
32
+ return c
33
+ }
34
+
35
+ func (c * redis.Pool ) releaseConn () {
36
+ c .Close ()
37
+ }
38
+
39
+ func DoGet (userId string ) {
40
+ c := getConn ()
41
+ defer c .releaseConn ()
42
+ }
43
+
44
+ func PipeGet (userId string ) {
45
+ }
46
+ func Release () {
47
+ }
Original file line number Diff line number Diff line change 4
4
"github.com/garyburd/redigo/redis"
5
5
)
6
6
7
- //var conn redis.Conn
8
7
func newPool () * redis.Pool {
9
8
return & redis.Pool {
10
9
MaxIdle : 80 ,
@@ -21,29 +20,27 @@ func newPool() *redis.Pool {
21
20
22
21
var pool = newPool ()
23
22
24
- /*
25
- func Init()error{
26
- pool = newPool()
27
- }
28
- */
29
-
30
23
func getConn () redis.Conn {
31
24
c := pool .Get ()
32
25
return c
33
26
}
34
27
35
- func releaseConn (c * redis. Conn ) {
36
- ( * c ). Close ()
28
+ func releaseConn () error {
29
+ return nil
37
30
}
38
31
39
32
func DoGet (userId string ) {
40
- c := getConn ()
33
+ c := pool . Get ()
41
34
c .Do ("INCR" , userId )
42
- c .Close ()
35
+ defer c .Close ()
36
+ }
37
+
38
+ func GetActiveConnNum () int {
39
+ return pool .ActiveCount ()
43
40
}
44
41
45
42
func PipeGet (userId string ) {
46
- c := getConn ()
43
+ c := pool . Get ()
47
44
c .Send ("INCR" , userId )
48
- c .Close ()
45
+ defer c .Close ()
49
46
}
You can’t perform that action at this time.
0 commit comments