Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
03399a60
Unverified
Commit
03399a60
authored
Jun 23, 2025
by
jinjingroad
Committed by
GitHub
Jun 23, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: use the built-in max/min to simplify the code (#4781)
Signed-off-by:
jinjingroad
<
jinjingroad@sina.com
>
parent
e6e46049
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
4 deletions
+2
-4
cache.go
store/cache/cache.go
+2
-4
No files found.
store/cache/cache.go
View file @
03399a60
...
@@ -251,10 +251,8 @@ func (c *Cache) cleanup() {
...
@@ -251,10 +251,8 @@ func (c *Cache) cleanup() {
// cleanupOldest removes the oldest items if we're over the max items.
// cleanupOldest removes the oldest items if we're over the max items.
func
(
c
*
Cache
)
cleanupOldest
()
{
func
(
c
*
Cache
)
cleanupOldest
()
{
threshold
:=
c
.
config
.
MaxItems
/
5
// Remove 20% of max items at once
// Remove 20% of max items at once
if
threshold
<
1
{
threshold
:=
max
(
c
.
config
.
MaxItems
/
5
,
1
)
threshold
=
1
}
currentCount
:=
atomic
.
LoadInt64
(
&
c
.
itemCount
)
currentCount
:=
atomic
.
LoadInt64
(
&
c
.
itemCount
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment