forked from free-lancers/electricity_bill_calc_service
		
	feat(user):基本完成用户重设密码,待测。
This commit is contained in:
		
							
								
								
									
										31
									
								
								cache/repository.go
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								cache/repository.go
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | ||||
| package cache | ||||
|  | ||||
| import "time" | ||||
|  | ||||
| func CacheData[T interface{}](instance T, category string, key ...string) error { | ||||
| 	var keys = make([]string, 0) | ||||
| 	keys = append(keys, category) | ||||
| 	keys = append(keys, key...) | ||||
| 	cacheKey := CacheKey("cache", keys...) | ||||
| 	if exists, _ := Exists(cacheKey); exists { | ||||
| 		Delete(cacheKey) | ||||
| 	} | ||||
| 	return Cache(cacheKey, &instance, 5*time.Minute) | ||||
| } | ||||
|  | ||||
| func RetreiveData[T interface{}](category string, key ...string) (*T, error) { | ||||
| 	var keys = make([]string, 0) | ||||
| 	keys = append(keys, category) | ||||
| 	keys = append(keys, key...) | ||||
| 	return Retreive[T](CacheKey("cache", keys...)) | ||||
| } | ||||
|  | ||||
| func AbolishCacheData(category string, key ...string) { | ||||
| 	var keys = make([]string, 0) | ||||
| 	keys = append(keys, category) | ||||
| 	keys = append(keys, key...) | ||||
| 	cacheKey := CacheKey("cache", keys...) | ||||
| 	if exists, _ := Exists(cacheKey); exists { | ||||
| 		Delete(cacheKey) | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user