mongodb용 세션 추가
This commit is contained in:
@ -11,58 +11,68 @@ import (
|
||||
)
|
||||
|
||||
func TestExpTable(t *testing.T) {
|
||||
pv, err := NewProvider(context.Background(), "redis://192.168.8.94:6380/1", 10*time.Second)
|
||||
// pv, err := NewProviderWithRedis(context.Background(), "redis://192.168.8.94:6380/1", 10*time.Second)
|
||||
// if err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
|
||||
// cs, err := NewConsumerWithRedis(context.Background(), "redis://192.168.8.94:6380/1", 10*time.Second)
|
||||
// if err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
|
||||
pv, err := NewProviderWithMongo(context.Background(), "mongodb://192.168.8.94:27017/?replicaSet=repl01&retrywrites=false", "maingate", 10*time.Second)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
cs, err := NewConsumer(context.Background(), "redis://192.168.8.94:6380/1", 10*time.Second)
|
||||
cs, err := NewConsumerWithMongo(context.Background(), "mongodb://192.168.8.94:27017/?replicaSet=repl01&retrywrites=false", "maingate", 10*time.Second)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
newid1 := primitive.NewObjectID()
|
||||
newid2 := primitive.NewObjectID()
|
||||
sk1 := primitive.NewObjectID().Hex()
|
||||
sk2 := primitive.NewObjectID().Hex()
|
||||
go func() {
|
||||
for {
|
||||
logger.Println("query :", cs.Query(newid1.Hex()))
|
||||
logger.Println("query :", cs.Query(newid2.Hex()))
|
||||
logger.Println("query :", cs.Query(sk1))
|
||||
logger.Println("query :", cs.Query(sk2))
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}()
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
pv.Update(newid1.Hex(), &Authorization{
|
||||
Account: newid1.Hex(),
|
||||
pv.Update(sk1, &Authorization{
|
||||
Account: primitive.NewObjectID(),
|
||||
Platform: "editor",
|
||||
Uid: "uid-1",
|
||||
})
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
pv.Update(newid2.Hex(), &Authorization{
|
||||
Account: newid2.Hex(),
|
||||
pv.Update(sk2, &Authorization{
|
||||
Account: primitive.NewObjectID(),
|
||||
Platform: "editor",
|
||||
Uid: "uid-2",
|
||||
})
|
||||
|
||||
cs.Touch(newid1.Hex())
|
||||
cs.Touch(sk1)
|
||||
time.Sleep(2 * time.Second)
|
||||
cs.Touch(newid2.Hex())
|
||||
cs.Touch(sk2)
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
pv.Delete(newid1.Hex())
|
||||
pv.Delete(sk1)
|
||||
|
||||
cs.Touch(newid1.Hex())
|
||||
cs.Touch(sk1)
|
||||
time.Sleep(2 * time.Second)
|
||||
cs.Touch(newid2.Hex())
|
||||
cs.Touch(sk2)
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
cs2, err := NewConsumer(context.Background(), "redis://192.168.8.94:6380/1", 10*time.Second)
|
||||
cs2, err := NewConsumerWithRedis(context.Background(), "redis://192.168.8.94:6380/1", 10*time.Second)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
logger.Println("queryf :", cs2.Query(newid2.Hex()))
|
||||
logger.Println("queryf :", cs2.Query(sk2))
|
||||
time.Sleep(20 * time.Second)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user