|
18 | 18 | Marshal func(v any) ([]byte, error) = json.Marshal |
19 | 19 | // Unmarshal 默认反序列化方案 |
20 | 20 | Unmarshal func(data []byte, v any) error = json.Unmarshal |
21 | | - // Expiration 缓存默认过期时间 |
22 | | - Expiration time.Duration |
| 21 | + // DefaultExpiration 缓存默认过期时间 |
| 22 | + DefaultExpiration time.Duration = time.Hour * 24 |
23 | 23 | // Disabled 缓存开关 |
24 | 24 | Disabled bool |
25 | 25 | // 缓存键名分隔符 |
@@ -99,7 +99,7 @@ func GetEntityByID[T CacheableEntity[INT], INT constraints.Integer]( |
99 | 99 | if data, err = Marshal(entity); err != nil { |
100 | 100 | return nil, errors.WithStack(err) |
101 | 101 | } |
102 | | - if err = cache.Set(ctx, key, data, Expiration); err != nil { |
| 102 | + if err = cache.Set(ctx, key, data, DefaultExpiration); err != nil { |
103 | 103 | return nil, errors.WithStack(err) |
104 | 104 | } |
105 | 105 |
|
@@ -159,7 +159,7 @@ func GetEntitiesByID[T CacheableEntity[INT], INT constraints.Integer]( |
159 | 159 | if data, err = Marshal(&items); err != nil { |
160 | 160 | return nil, errors.WithStack(err) |
161 | 161 | } |
162 | | - if err = cache.Set(ctx, key, data, Expiration); err != nil { |
| 162 | + if err = cache.Set(ctx, key, data, DefaultExpiration); err != nil { |
163 | 163 | return nil, errors.WithStack(err) |
164 | 164 | } |
165 | 165 |
|
|
0 commit comments