From dba8f6f3ca274bcf339bdd7a662f582e4a9fd9dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Thu, 25 Aug 2022 09:50:55 +0800 Subject: [PATCH] =?UTF-8?q?enhance(cache):=E9=83=A8=E5=88=86=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=87=BD=E6=95=B0=E8=BF=94=E5=9B=9E=E7=A9=BA=E6=8C=87?= =?UTF-8?q?=E9=92=88=E4=BB=A5=E8=A1=A8=E7=A4=BA=E6=9C=AA=E5=8F=96=E5=88=B0?= =?UTF-8?q?=E4=BB=BB=E4=BD=95=E5=86=85=E5=AE=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cache/entity.go | 4 ++-- cache/search.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cache/entity.go b/cache/entity.go index 7f945f5..3a8d71d 100644 --- a/cache/entity.go +++ b/cache/entity.go @@ -25,10 +25,10 @@ func CacheEntity[T any](instance T, entityName, id string) error { } // 从缓存中取出模型名称明确的,使用ID进行检索的实体内容。 -func RetreiveEntity[T any](entityName, id string) (T, error) { +func RetreiveEntity[T any](entityName, id string) (*T, error) { entityKey := assembleEntityKey(entityName, id) instance, err := Retreive[T](entityKey) - return *instance, err + return instance, err } // 精确的从缓存中删除指定模型名称、指定ID的实体内容。 diff --git a/cache/search.go b/cache/search.go index 3312b52..8376663 100644 --- a/cache/search.go +++ b/cache/search.go @@ -26,10 +26,10 @@ func CacheSearch[T any](instance T, entityName string, conditions ...string) err } // 从缓存中取得模型名称明确的,使用或者包含非ID检索条件的实体内容。 -func RetreiveSearch[T any](entityName string, conditions ...string) (T, error) { +func RetreiveSearch[T any](entityName string, conditions ...string) (*T, error) { searchKey := assembleSearchKey(entityName, conditions...) instance, err := Retreive[T](searchKey) - return *instance, err + return instance, err } // 从缓存中删除全部指定模型名称的实体内容。