fix: [#625] Throttle doesn't work when using the Redis cache driver#955
fix: [#625] Throttle doesn't work when using the Redis cache driver#955
Conversation
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.
| Benchmark suite | Current: 23482c8 | Previous: ab139f2 | Ratio |
|---|---|---|---|
Benchmark_EncryptString |
6751 ns/op 2160 B/op 15 allocs/op |
2299 ns/op 2160 B/op 15 allocs/op |
2.94 |
Benchmark_EncryptString - ns/op |
6751 ns/op |
2299 ns/op |
2.94 |
Benchmark_DecryptString |
6659 ns/op 2040 B/op 17 allocs/op |
2100 ns/op 2040 B/op 17 allocs/op |
3.17 |
Benchmark_DecryptString - ns/op |
6659 ns/op |
2100 ns/op |
3.17 |
This comment was automatically generated by workflow using github-action-benchmark.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v1.15.x #955 +/- ##
==========================================
Coverage ? 68.60%
==========================================
Files ? 219
Lines ? 18957
Branches ? 0
==========================================
Hits ? 13006
Misses ? 5284
Partials ? 667 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| } | ||
|
|
||
| nb := NewBucket(s.tokens, s.interval) | ||
| if err := s.cache.Put(key, nb, s.interval); err != nil { |
There was a problem hiding this comment.
The bug is caused by this line, struct can't be stored in Redis directly, Put will return an error here. It means this feature can't be used entirely when using the Redis driver. Through this thing, I think the next major work is to improve test coverage, before more people use the framework. cc @goravel/core-developers
| return r.BlockWithTicker(t, 1*time.Second, callback...) | ||
| } | ||
|
|
||
| func (r *Lock) BlockWithTicker(t time.Duration, ti time.Duration, callback ...func()) bool { |
There was a problem hiding this comment.
Previously, the default ticker is 1 second, we want to customize the ticker in Throttle. Otherwise, the request will very slow when checking throttle (1s * N).
📑 Description
Closes goravel/goravel#625
✅ Checks