From 5b4761e4e59122345c2d758b281240ffdb017f37 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Tue, 18 Jun 2019 23:34:16 +0300 Subject: [PATCH] Fixes #9. Start GC loop for in-memory textures cache. --- CHANGELOG.md | 5 ++++- api/mojang/queue/in_memory_textures_storage.go | 5 ++++- api/mojang/queue/in_memory_textures_storage_test.go | 2 -- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2484c82..1f10c6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [Unreleased] - xxxx-xx-xx + +### Fixed +- GC for in-memory textures cache has not been initialized. ## [4.2.1] - 2019-05-06 ### Changed diff --git a/api/mojang/queue/in_memory_textures_storage.go b/api/mojang/queue/in_memory_textures_storage.go index 1b8bc00..31c9294 100644 --- a/api/mojang/queue/in_memory_textures_storage.go +++ b/api/mojang/queue/in_memory_textures_storage.go @@ -25,9 +25,12 @@ type inMemoryTexturesStorage struct { } func CreateInMemoryTexturesStorage() *inMemoryTexturesStorage { - return &inMemoryTexturesStorage{ + storage := &inMemoryTexturesStorage{ data: make(map[string]*inMemoryItem), } + storage.Start() + + return storage } func (s *inMemoryTexturesStorage) Start() { diff --git a/api/mojang/queue/in_memory_textures_storage_test.go b/api/mojang/queue/in_memory_textures_storage_test.go index 1e90812..019da74 100644 --- a/api/mojang/queue/in_memory_textures_storage_test.go +++ b/api/mojang/queue/in_memory_textures_storage_test.go @@ -178,8 +178,6 @@ func TestInMemoryTexturesStorage_GarbageCollection(t *testing.T) { storage.StoreTextures("dead24f9a4fa4877b7b04c8c6c72bb46", textures1) storage.StoreTextures("b5d58475007d4f9e9ddd1403e2497579", textures2) - storage.Start() - time.Sleep(inMemoryStorageGCPeriod + time.Millisecond) // Let it start first iteration _, textures1Err := storage.GetTextures("dead24f9a4fa4877b7b04c8c6c72bb46")