cache: use badgerdb (#15)

This commit is contained in:
l3uddz
2021-02-19 22:20:02 +00:00
committed by GitHub
parent e1945cf714
commit 5b179ed8dc
13 changed files with 175 additions and 77 deletions

9
cache/put_test.go vendored
View File

@@ -34,7 +34,7 @@ func TestClient_Put(t *testing.T) {
bucket: "put",
key: "test",
val: []byte("testing"),
ttl: 50 * time.Millisecond,
ttl: 5 * time.Second,
},
want: []byte("testing"),
wantErr: false,
@@ -48,9 +48,9 @@ func TestClient_Put(t *testing.T) {
bucket: "put",
key: "test",
val: []byte("testing"),
ttl: 1 * time.Second,
ttl: 500 * time.Millisecond,
},
sleep: 2 * time.Second,
sleep: 1 * time.Second,
want: nil,
wantErr: true,
},
@@ -65,6 +65,7 @@ func TestClient_Put(t *testing.T) {
val: []byte("testing"),
ttl: 0,
},
sleep: 1 * time.Second,
want: []byte("testing"),
wantErr: false,
},
@@ -73,7 +74,7 @@ func TestClient_Put(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
c := &Client{
log: tt.fields.log,
db: newDb(t, "nabarr_put"),
db: newDb(t),
}
if err := c.Put(tt.args.bucket, tt.args.key, tt.args.val, tt.args.ttl); (err != nil) != tt.wantErr && tt.sleep == 0 {