Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add Cap interface{} #145

Merged
merged 5 commits into from Jan 10, 2024
Merged

feature: add Cap interface{} #145

merged 5 commits into from Jan 10, 2024

Conversation

zhuliquan
Copy link
Contributor

add Cap func for getting the capacity of the cache. it's helpful for computing usage ratio of cache

@hashicorp-cla
Copy link

hashicorp-cla commented Jul 28, 2023

CLA assistant check
All committers have signed the CLA.

@mgaffney mgaffney self-assigned this Aug 1, 2023
arc/arc.go Outdated
@@ -202,6 +202,11 @@ func (c *ARCCache[K, V]) Len() int {
return c.t1.Len() + c.t2.Len()
}

// Cap returns the capacity of cache
func (c *ARCCache[K, V]) Cap() int {
return c.Cap()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This results in an infinite recursive call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This results in an infinite recursive call.

Thank for your reviewing, I have fix it

@mgaffney
Copy link
Member

mgaffney commented Jan 9, 2024

@zhuliquan can you update this PR to resolve the conflicts. Once that is done, I will merge it. Sorry for the delay.

@zhuliquan
Copy link
Contributor Author

@zhuliquan can you update this PR to resolve the conflicts. Once that is done, I will merge it. Sorry for the delay.

Yes, I have resolved

@mgaffney
Copy link
Member

Your branch still has conflicts. Can you rebase off of main instead of doing a merge from main?

@zhuliquan
Copy link
Contributor Author

@zhuliquan can you update this PR to resolve the conflicts. Once that is done, I will merge it. Sorry for the delay.

I'am very confused, all tests is ok before. Three are some cases is wrong, when I rung go test -v ./...
error info as below:

--- FAIL: TestLRUWithPurge (0.32s)
    expirable_lru_test.go:257: length differs from expected
--- FAIL: TestLoadingExpired (0.12s)
    expirable_lru_test.go:405: length differs from expected
--- FAIL: ExampleLRU (0.12s)

@mgaffney
Copy link
Member

I don't get those errors when I run the tests

@mgaffney mgaffney merged commit d582c45 into hashicorp:main Jan 10, 2024
2 checks passed
@zhuliquan
Copy link
Contributor Author

I don't get those errors when I run the tests

Case (TestLRUWithPurge) isn't ok until I add more wait time (i.g. 2000 * time.Millisecond). are there some bugs in expire operation?

time.Sleep(200 * time.Millisecond) // expire

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants