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 } // 从缓存中删除全部指定模型名称的实体内容。