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

fixed item behavior #6

Merged
merged 4 commits into from
Nov 28, 2021
Merged

fixed item behavior #6

merged 4 commits into from
Nov 28, 2021

Conversation

Code-Hex
Copy link
Owner

  • fixed item behavior (added an item option)
  • adjust Cache interface
  • added some methods to simple package

@codecov
Copy link

codecov bot commented Nov 28, 2021

Codecov Report

Merging #6 (4e9b01a) into main (ade978f) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main        #6   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines          138       158   +20     
=========================================
+ Hits           138       158   +20     
Impacted Files Coverage Δ
cache.go 100.00% <100.00%> (ø)
lru/lru.go 100.00% <100.00%> (ø)
simple/simple.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ade978f...4e9b01a. Read the comment docs.

@Code-Hex Code-Hex merged commit 61d859c into main Nov 28, 2021
@Code-Hex Code-Hex deleted the fix/item-behavior branch November 28, 2021 07:30
@@ -77,7 +75,8 @@ func (c *Cache[K, V]) Keys() []K {
defer c.mu.RUnlock()
keys := make([]K, 0, len(c.items))
for ent := c.list.Back(); ent != nil; ent = ent.Prev() {
keys = append(keys, ent.Value.(*item[K, V]).Key)
item := ent.Value.(*cache.Item[K, V])
keys = append(keys, item.Key)
}
Copy link

@lzap lzap Sep 16, 2022

Choose a reason for hiding this comment

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

Isn't this faster?

	keys := make([]K, len(c.items))
        i := 0
	for ent := c.list.Back(); ent != nil; ent = ent.Prev() {
		item := ent.Value.(*cache.Item[K, V])
		keys[i] = item.Key
                i += 1
	}

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

2 participants