forked from free-lancers/electricity_bill_calc_service
		
	enhance(cache):部分获取函数返回空指针以表示未取到任何内容。
This commit is contained in:
		
							
								
								
									
										4
									
								
								cache/entity.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								cache/entity.go
									
									
									
									
										vendored
									
									
								
							| @@ -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的实体内容。 | ||||
|   | ||||
							
								
								
									
										4
									
								
								cache/search.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								cache/search.go
									
									
									
									
										vendored
									
									
								
							| @@ -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 | ||||
| } | ||||
|  | ||||
| // 从缓存中删除全部指定模型名称的实体内容。 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user