Improve caching, move mutex to the cache implementation

This commit is contained in:
2023-08-24 23:53:52 +03:00
parent 49c962e13c
commit acb9f97806
4 changed files with 42 additions and 28 deletions

View File

@@ -70,7 +70,9 @@ func TestLogs_Get(t *testing.T) {
})
require.NoError(t, err)
ctx := context.Background()
ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)
logger := zaptest.NewLogger(t)
require.NoError(t, application.Migrate(ctx, db, logger))
@@ -96,7 +98,7 @@ func TestLogs_Get(t *testing.T) {
_, err = db.NewInsert().Model(&testData).Exec(ctx)
require.NoError(t, err)
repo, err := NewConnLogs(ctx, db, make(inmemorycache.Cache), logger, time.Millisecond*100)
repo, err := NewConnLogs(ctx, db, inmemorycache.NewCache(), logger, time.Millisecond*100)
require.NoError(t, err)
t.Run("found dup", func(t *testing.T) {