From bfe447f6587dbb534350b7c4f9b89f4496bde1b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksa=20Siri=C5=A1ki?= <31509435+aleksasiriski@users.noreply.github.com> Date: Mon, 21 Oct 2024 22:41:56 +0200 Subject: [PATCH] fix(cache): remove duplicate function for combining into key --- src/cache/actions.go | 9 --------- src/cache/actions_currencies.go | 3 ++- src/cache/actions_results.go | 3 ++- 3 files changed, 4 insertions(+), 11 deletions(-) delete mode 100644 src/cache/actions.go diff --git a/src/cache/actions.go b/src/cache/actions.go deleted file mode 100644 index 76d433a3..00000000 --- a/src/cache/actions.go +++ /dev/null @@ -1,9 +0,0 @@ -package cache - -func combineIntoKey(elem ...string) string { - key := "" - for _, e := range elem { - key += e - } - return key -} diff --git a/src/cache/actions_currencies.go b/src/cache/actions_currencies.go index fa380942..0e8a3cfe 100644 --- a/src/cache/actions_currencies.go +++ b/src/cache/actions_currencies.go @@ -5,6 +5,7 @@ import ( "github.com/hearchco/agent/src/exchange/currency" "github.com/hearchco/agent/src/exchange/engines" + "github.com/hearchco/agent/src/utils/morestrings" ) func (db DB) SetCurrencies(base currency.Currency, engs []engines.Name, currencies currency.Currencies, ttl ...time.Duration) error { @@ -31,5 +32,5 @@ func combineBaseWithExchangeEnginesNames(base currency.Currency, engs []engines. } baseWithEnginesNamesStrings := append(enginesNamesStrings, base.String()) - return combineIntoKey(baseWithEnginesNamesStrings...) + return morestrings.JoinNonEmpty("", "_", baseWithEnginesNamesStrings...) } diff --git a/src/cache/actions_results.go b/src/cache/actions_results.go index 7891eb0e..3f95aafb 100644 --- a/src/cache/actions_results.go +++ b/src/cache/actions_results.go @@ -7,6 +7,7 @@ import ( "github.com/hearchco/agent/src/search/category" "github.com/hearchco/agent/src/search/engines/options" "github.com/hearchco/agent/src/search/result" + "github.com/hearchco/agent/src/utils/morestrings" ) func (db DB) SetResults(q string, cat category.Name, opts options.Options, results []result.Result, ttl ...time.Duration) error { @@ -44,7 +45,7 @@ func (db DB) GetResultsTTL(q string, cat category.Name, opts options.Options) (t } func combineQueryWithOptions(q string, cat category.Name, opts options.Options) string { - return combineIntoKey( + return morestrings.JoinNonEmpty("", "_", q, cat.String(), strconv.Itoa(opts.Pages.Start), strconv.Itoa(opts.Pages.Max), opts.Locale.String(), strconv.FormatBool(opts.SafeSearch),