Skip to content

Commit 5888749

Browse files
authored
Add error logs for fn queries (#54)
* docs: update * style: update * docs: update * docs: update * docs: update * docs: update * feat: Add error logs for fn queries * docs: update * docs: update
1 parent fd9f9de commit 5888749

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

cachegeneric.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ func (w *T[K, V]) mQueryAndSetCache(ctx context.Context, miss map[string]K, fn f
200200
c.statsHandler.IncrQuery()
201201
fnValues, err := fn(ctx, missIds)
202202
if err != nil {
203+
logger.Error("mQueryAndSetCache#fn(%v) error(%v)", missIds, err)
203204
c.statsHandler.IncrQueryFail(err)
204205
return nil
205206
}

docs/CN/Config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
| remote | `remote.Remote` 接口 | nil | remote 是分布式缓存,例如 Redis。也可以自定义,实现`remote.Remote`接口即可 |
1717
| local | `local.Local` 接口 | nil | local 是内存缓存,例如 FreeCache、TinyLFU。也可以自定义,实现`local.Local`接口即可 |
1818
| codec | string | msgpack | value的编码和解码方法。默认为 "msgpack"。可选:`json` \| `msgpack` \| `sonic`,也可以自定义,实现`encoding.Codec`接口并注册即可 |
19-
| errNotFound | error | nil | 缓存未命中时返回的错误,例:`gorm.ErrRecordNotFound`。用于防止缓存穿透(即缓存空对象) |
19+
| errNotFound | error | nil | 回源记录不存在时返回的错误,例:`gorm.ErrRecordNotFound`。用于防止缓存穿透(即缓存空对象) |
2020
| remoteExpiry | `time.Duration` | 1小时 | 远程缓存 TTL,默认为 1 小时 |
2121
| notFoundExpiry | `time.Duration` | 1分钟 | 缓存未命中时占位符缓存的过期时间。默认为 1 分钟 |
2222
| offset | `time.Duration` | (0,10]| 缓存未命中时的过期时间抖动因子 |

docs/EN/Config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
| remote | `remote.Remote` interface | nil | Distributed cache, such as Redis. Can be customized by implementing the `remote.Remote` interface. |
1717
| local | `local.Local` interface | nil | In-memory cache, such as FreeCache, TinyLFU. Can be customized by implementing the `local.Local` interface. |
1818
| codec | string | msgpack | Encoding and decoding method for values. Defaults to "msgpack". Options: `json` \| `msgpack` \| `sonic`. Can be customized by implementing the `encoding.Codec` interface and registering it. |
19-
| errNotFound | error | nil | Error returned when a cache miss occurs, e.g., `gorm.ErrRecordNotFound`. Used to prevent cache penetration (i.e., caching empty objects). |
19+
| errNotFound | error | nil | Error returned when an origin record is not found, e.g., `gorm.ErrRecordNotFound`. Used to prevent cache penetration (i.e., caching empty objects). |
2020
| remoteExpiry | `time.Duration` | 1 hour | Remote cache TTL, defaults to 1 hour. |
2121
| notFoundExpiry | `time.Duration` | 1 minute | Expiration time for placeholder caches when a cache miss occurs. Defaults to 1 minute. |
2222
| offset | `time.Duration` | (0,10] seconds | Expiration time jitter factor for cache misses. |

0 commit comments

Comments
 (0)