Code Monkey home page Code Monkey logo

Comments (7)

Code-Hex avatar Code-Hex commented on May 30, 2024

@RelicOfTesla Do you have any plans?

from go-generics-cache.

RelicOfTesla avatar RelicOfTesla commented on May 30, 2024

use Priority Queue.
like https://github.com/jellydator/ttlcache/blob/v3/expiration_queue_test.go

https://github.com/oleiade/lane

https://github.com/rdleal/go-priorityq/blob/main/kpq/keyed_priority_queue_test.go#L42

from go-generics-cache.

Code-Hex avatar Code-Hex commented on May 30, 2024

@RelicOfTesla I have released v1.4.0.

from go-generics-cache.

RelicOfTesla avatar RelicOfTesla commented on May 30, 2024

@Code-Hex Still scanning with all key??? You only need to check if the top items in the priority queue have expired.

from go-generics-cache.

Code-Hex avatar Code-Hex commented on May 30, 2024

@RelicOfTesla not all scanned

go-generics-cache/cache.go

Lines 231 to 251 in 5303a9a

evict := func() bool {
key := c.expManager.pop()
// if is expired, delete it and return nil instead
item, ok := c.cache.Get(key)
if ok {
if item.Expired() {
c.cache.Delete(key)
return false
}
c.expManager.update(key, item.Expiration)
}
return true
}
for i := 0; i < l; i++ {
c.mu.Lock()
shouldBreak := evict()
c.mu.Unlock()
if shouldBreak {
break
}

from go-generics-cache.

RelicOfTesla avatar RelicOfTesla commented on May 30, 2024

Well, I read it wrong, but you only deleted one element ??

from go-generics-cache.

Code-Hex avatar Code-Hex commented on May 30, 2024

@RelicOfTesla No, Please read my test cases. I tested them

#48

from go-generics-cache.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.