|
|
@ -286,7 +286,7 @@ func TestStatCacheFails(t *testing.T) {
|
|
|
|
log.SetOutput(ioutil.Discard)
|
|
|
|
log.SetOutput(ioutil.Discard)
|
|
|
|
defer log.SetOutput(os.Stdout)
|
|
|
|
defer log.SetOutput(os.Stdout)
|
|
|
|
|
|
|
|
|
|
|
|
r := redis.NewRedis("localhost:59999", redis.NodeType)
|
|
|
|
r := redis.New("localhost:59999")
|
|
|
|
c := NewNodeConn(dummySqlConn{}, r, cache.WithExpiry(time.Second*10))
|
|
|
|
c := NewNodeConn(dummySqlConn{}, r, cache.WithExpiry(time.Second*10))
|
|
|
|
|
|
|
|
|
|
|
|
for i := 0; i < 20; i++ {
|
|
|
|
for i := 0; i < 20; i++ {
|
|
|
@ -485,7 +485,7 @@ func TestCachedConnExecDropCache(t *testing.T) {
|
|
|
|
value = "any"
|
|
|
|
value = "any"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
var conn trackedConn
|
|
|
|
var conn trackedConn
|
|
|
|
c := NewNodeConn(&conn, redis.NewRedis(r.Addr(), redis.NodeType), cache.WithExpiry(time.Second*30))
|
|
|
|
c := NewNodeConn(&conn, redis.New(r.Addr()), cache.WithExpiry(time.Second*30))
|
|
|
|
assert.Nil(t, c.SetCache(key, value))
|
|
|
|
assert.Nil(t, c.SetCache(key, value))
|
|
|
|
_, err = c.Exec(func(conn sqlx.SqlConn) (result sql.Result, e error) {
|
|
|
|
_, err = c.Exec(func(conn sqlx.SqlConn) (result sql.Result, e error) {
|
|
|
|
return conn.Exec("delete from user_table where id='kevin'")
|
|
|
|
return conn.Exec("delete from user_table where id='kevin'")
|
|
|
@ -503,7 +503,7 @@ func TestCachedConnExecDropCache(t *testing.T) {
|
|
|
|
func TestCachedConnExecDropCacheFailed(t *testing.T) {
|
|
|
|
func TestCachedConnExecDropCacheFailed(t *testing.T) {
|
|
|
|
const key = "user"
|
|
|
|
const key = "user"
|
|
|
|
var conn trackedConn
|
|
|
|
var conn trackedConn
|
|
|
|
r := redis.NewRedis("anyredis:8888", redis.NodeType)
|
|
|
|
r := redis.New("anyredis:8888")
|
|
|
|
c := NewNodeConn(&conn, r, cache.WithExpiry(time.Second*10))
|
|
|
|
c := NewNodeConn(&conn, r, cache.WithExpiry(time.Second*10))
|
|
|
|
_, err := c.Exec(func(conn sqlx.SqlConn) (result sql.Result, e error) {
|
|
|
|
_, err := c.Exec(func(conn sqlx.SqlConn) (result sql.Result, e error) {
|
|
|
|
return conn.Exec("delete from user_table where id='kevin'")
|
|
|
|
return conn.Exec("delete from user_table where id='kevin'")
|
|
|
|