Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update imports #11

Merged
merged 4 commits into from
Feb 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ VCacheAdd-12 8966773 761.1 ns/op 213 B/op
VCacheGet-12 39050804 184.0 ns/op 7 B/op 0 allocs/op
VCacheDelete-12 36885169 192.3 ns/op 7 B/op 0 allocs/op
VCacheEvict-12 23756037 248.5 ns/op 0 B/op 0 allocs/op
VCacheMixed-12 1000000 7607 ns/op 110 B/op 7 allocs/op
VCacheMixed-12 9602469 791.1 ns/op 154 B/op 7 allocs/op
```
The results of comparison with another library [go-cache](https://github.com/patrickmn/go-cache) are also presented:
```
Expand Down
4 changes: 2 additions & 2 deletions cache_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

cache "microup.ru/vcache"
cache "github.com/microup/vcache"
)

func BenchmarkCacheAdd(b *testing.B) {
Expand Down Expand Up @@ -73,7 +73,7 @@ func BenchmarkCacheEvict(b *testing.B) {
}

func BenchmarkCacheMixed(b *testing.B) {
cacheTest := cache.New(1*time.Nanosecond, 1*time.Nanosecond)
cacheTest := cache.New(2*time.Second, 1*time.Nanosecond)
cacheTest.StartEvict(context.Background())

for i := 0; i < b.N; i++ {
Expand Down
2 changes: 1 addition & 1 deletion cache_fuzzing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"
"time"

cache "microup.ru/vcache"
cache "github.com/microup/vcache"
)

func TestFuzzing_Add(t *testing.T) {
Expand Down
27 changes: 25 additions & 2 deletions cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

cache "microup.ru/vcache"
cache "github.com/microup/vcache"
)

func TestStartEvict(t *testing.T) {
Expand Down Expand Up @@ -100,7 +100,7 @@ func TestCache_Delete(t *testing.T) {

// Adding a key-value pair to the cache
err := cacheInstance.Add("key1", "value1")

if err != nil {
t.Errorf("failed add key %v", err)
}
Expand All @@ -120,3 +120,26 @@ func TestCache_Delete(t *testing.T) {
t.Error("Key-value pair was not deleted from the cache")
}
}

func TestDifferentTypes(t *testing.T) {
t.Parallel()

timeCheckNewTicker := 1 * time.Second
timeRecordEvict := 10 * time.Second

cacheInstance := cache.New(timeCheckNewTicker, timeRecordEvict)

searchValue := "12345678"

err := cacheInstance.Add(0.75513, searchValue)

if err != nil {
t.Errorf("failed add key %v", err)
}

value, foundKey := cacheInstance.Get(0.75513)

if !foundKey || value != searchValue {
t.Errorf("expected value to be %s but got %s", searchValue, value)
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module microup.ru/vcache
module github.com/microup/vcache

go 1.19