Skip to content

Commit

Permalink
release: v0.0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuigo committed Dec 5, 2023
1 parent da9b240 commit 55278a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

This **gofnext** provides the following functions extended.
- Cache decorators: Similar to Python's `functools.cache` and `functools.lru_cache`.
- Additionally, it supports Redis caching and custom caching.
- In addition to memory cache, it also supports Redis caching and custom caching.

TOC
- [Go function extended(go\>=1.21)](#go-function-extendedgo121)
Expand Down Expand Up @@ -53,7 +53,6 @@ TOC
## Decorator examples
Refer to: [examples](https://github.com/ahuigo/gofnext/blob/main/examples)


### Cache fibonacii function
Refer to: [decorator fib example](https://github.com/ahuigo/gofnext/blob/main/examples/decorator-fib_test.go)

Expand Down Expand Up @@ -209,6 +208,19 @@ Refer to: [decorator example](https://github.com/ahuigo/gofnext/blob/main/exampl
### Cache function with lru cache
Refer to: [decorator lru example](https://github.com/ahuigo/gofnext/blob/main/examples/decorator-lru_test.go)

executeCount := 0
maxCacheSize := 2
var getUserScore = func(more int) (int, error) {
executeCount++
return 98 + more, errors.New("db error")
}

// Cacheable Function
var getUserScoreFromDbWithLruCache = gofnext.CacheFn1Err(getUserScore, &gofnext.Config{
TTL: time.Hour,
CacheMap: gofnext.NewCacheLru(maxCacheSize),
})

### Cache function with redis cache
> Warning: Since redis needs JSON marshaling, this may result in data loss.
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.0.13
v0.0.14

0 comments on commit 55278a8

Please sign in to comment.