@@ -25,7 +25,6 @@ func NewWithCleanupInterval(db *sql.DB, cleanupInterval time.Duration) *GodrorSt
25
25
}
26
26
27
27
func (g * GodrorStore ) Find (token string ) (b []byte , exists bool , err error ) {
28
- fmt .Println ("Find" )
29
28
stmt := fmt .Sprintf ("SELECT data FROM sessions WHERE token = '%x' AND current_timestamp < expiry" , token )
30
29
row := g .db .QueryRow (stmt )
31
30
err = row .Scan (& b )
@@ -38,12 +37,10 @@ func (g *GodrorStore) Find(token string) (b []byte, exists bool, err error) {
38
37
}
39
38
40
39
func (g * GodrorStore ) Commit (token string , b []byte , expiry time.Time ) error {
41
- fmt .Println ("Commit" )
42
40
stmt := fmt .Sprintf ("SELECT data FROM sessions WHERE token = '%x'" , token )
43
41
row := g .db .QueryRow (stmt )
44
42
err := row .Err ()
45
43
if row .Scan () == sql .ErrNoRows {
46
- fmt .Println ("No Row Found" )
47
44
stmt = `INSERT INTO sessions (token, data, expiry) VALUES ('%x', '%x', to_timestamp('` + string (expiry .Format ("2006-01-02 15:04:05.00" )) + `', 'YYYY-MM-DD HH24:MI:SS.FF'))`
48
45
stmt = fmt .Sprintf (stmt , token , b )
49
46
fmt .Println (stmt )
@@ -53,11 +50,9 @@ func (g *GodrorStore) Commit(token string, b []byte, expiry time.Time) error {
53
50
}
54
51
return nil
55
52
} else if err != nil {
56
- fmt .Println ("Other error" )
57
53
return err
58
54
}
59
55
60
- fmt .Println ("Update session data" )
61
56
stmt = `UPDATE sessions SET data = '%x', expiry = to_timestamp('` + string (expiry .Format ("2006-01-02 15:04:05.00" )) + `', 'YYYY-MM-DD HH24:MI:SS.FF') WHERE token = '%x'`
62
57
stmt = fmt .Sprintf (stmt , b , token )
63
58
_ , err = g .db .Exec (stmt )
@@ -69,14 +64,12 @@ func (g *GodrorStore) Commit(token string, b []byte, expiry time.Time) error {
69
64
}
70
65
71
66
func (g * GodrorStore ) Delete (token string ) error {
72
- fmt .Println ("Delete" )
73
67
stmt := fmt .Sprintf ("DELETE FROM session WHERE token = '%x'" , token )
74
68
_ , err := g .db .Exec (stmt )
75
69
return err
76
70
}
77
71
78
72
func (g * GodrorStore ) All () (map [string ][]byte , error ) {
79
- fmt .Println ("All" )
80
73
rows , err := g .db .Query ("SELECT token, data FROM sessions WHERE current_timestamp < expiry" )
81
74
if err != nil {
82
75
return nil , err
@@ -108,7 +101,6 @@ func (g *GodrorStore) All() (map[string][]byte, error) {
108
101
}
109
102
110
103
func (g * GodrorStore ) StartCleanup (interval time.Duration ) {
111
- fmt .Println ("StartCleanup" )
112
104
g .stopCleanup = make (chan bool )
113
105
ticker := time .NewTicker (interval )
114
106
for {
@@ -126,14 +118,12 @@ func (g *GodrorStore) StartCleanup(interval time.Duration) {
126
118
}
127
119
128
120
func (g * GodrorStore ) StopCleanup () {
129
- fmt .Println ("StopCleanup" )
130
121
if g .stopCleanup != nil {
131
122
g .stopCleanup <- true
132
123
}
133
124
}
134
125
135
126
func (g * GodrorStore ) deleteExpired () error {
136
- fmt .Println ("deleteExpired" )
137
127
_ , err := g .db .Exec ("DELETE FROM sessions WHERE expiry < current_timestamp" )
138
128
return err
139
129
}
0 commit comments