enhance(cache):部分获取函数返回空指针以表示未取到任何内容。

This commit is contained in:
徐涛 2022-08-25 09:50:55 +08:00
parent 4025965e98
commit dba8f6f3ca
2 changed files with 4 additions and 4 deletions

4
cache/entity.go vendored
View File

@ -25,10 +25,10 @@ func CacheEntity[T any](instance T, entityName, id string) error {
} }
// 从缓存中取出模型名称明确的使用ID进行检索的实体内容。 // 从缓存中取出模型名称明确的使用ID进行检索的实体内容。
func RetreiveEntity[T any](entityName, id string) (T, error) { func RetreiveEntity[T any](entityName, id string) (*T, error) {
entityKey := assembleEntityKey(entityName, id) entityKey := assembleEntityKey(entityName, id)
instance, err := Retreive[T](entityKey) instance, err := Retreive[T](entityKey)
return *instance, err return instance, err
} }
// 精确的从缓存中删除指定模型名称、指定ID的实体内容。 // 精确的从缓存中删除指定模型名称、指定ID的实体内容。

4
cache/search.go vendored
View File

@ -26,10 +26,10 @@ func CacheSearch[T any](instance T, entityName string, conditions ...string) err
} }
// 从缓存中取得模型名称明确的使用或者包含非ID检索条件的实体内容。 // 从缓存中取得模型名称明确的使用或者包含非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...) searchKey := assembleSearchKey(entityName, conditions...)
instance, err := Retreive[T](searchKey) instance, err := Retreive[T](searchKey)
return *instance, err return instance, err
} }
// 从缓存中删除全部指定模型名称的实体内容。 // 从缓存中删除全部指定模型名称的实体内容。