Skip to content

Commit

Permalink
doc: update default value
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuigo committed Oct 17, 2024
1 parent a48944c commit 9f62a0d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 2 additions & 0 deletions examples/decorator-err_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var (
getUserAndErrCached = gofnext.CacheFn0Err(getUserAndErr, nil)
)

// Test: if this is any error, do not cache error
func TestNoCacheIfErr(t *testing.T) {
times := 10
count.Store(0)
Expand All @@ -47,6 +48,7 @@ func TestNoCacheIfErr(t *testing.T) {
}
}

// Test: if this is any error, cache error
func TestNeedCacheIfErr(t *testing.T) {
count := atomic.Uint32{}
getUserAndErr := func(age int) (UserInfo, error) {
Expand Down
14 changes: 7 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,13 @@ Refer to: https://github.com/ahuigo/gofnext/blob/main/cache-map-mem.go
### Config item(`gofnext.Config`)
gofnext.Config item list:

| Key | Description |
|-----|------------------|
| TTL | Cache Time to Live |
| CacheMap|Custom own cache |
| NeedCacheIfErr | Enable cache even if there is an error |
| HashKeyPointerAddr | Use Pointer Addr as key instead of its value when hashing key |
| HashKeyFunc| Custom hash key function |
| Key | Description | Default |
|-----|------------------|--------------------|
| TTL | Cache Time to Live |0(No timeout) |
| CacheMap|Custom own cache | Inner Memory |
| NeedCacheIfErr | Enable cache even if there is an error | false |
| HashKeyPointerAddr | Use Pointer Addr(&p) as key instead of its value when hashing key |false(Use real value`*p` as key) |
| HashKeyFunc| Custom hash key function | Inner hash func|

### Cache Timeout
e.g.
Expand Down
12 changes: 6 additions & 6 deletions readme.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,13 @@ Set redis config:
### 配置项清单(`gofnext.Config`)
gofnext.Config 清单:

|| 描述|
|| 描述 |默认 |
|-----|------------------|
| TTL | 缓存时间 |
| CacheMap| 自定义缓存map |
| NeedCacheIfErr | 如果调用存在error,也要使用缓存 |
| HashKeyPointerAddr | 哈希键时,用指针本身地址,而不是指针的值 |
| HashKeyFunc| 自定义哈希键函数 |
| TTL | 缓存时间 | 0(不过期)|
| CacheMap| 自定义缓存map |默认内存Map|
| NeedCacheIfErr | 如果调用存在error,也要使用缓存 |有err就不缓存|
| HashKeyPointerAddr | 哈希key时,使用指针本身地址(&p),而不是实际的值 |默认使用pointer指向实际值(*p)|
| HashKeyFunc| 自定义哈希键函数 |内置hashFunc|

### 缓存时间
e.g.
Expand Down

0 comments on commit 9f62a0d

Please sign in to comment.