Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for GetOldest (0.04 sec)

  1. internal/lru/lru.go

    	c.mu.Lock()
    	defer c.mu.Unlock()
    	if ent := c.evictList.Back(); ent != nil {
    		c.removeElement(ent)
    		return ent.Key, ent.Value, true
    	}
    	return
    }
    
    // GetOldest returns the oldest entry
    func (c *LRU[K, V]) GetOldest() (key K, value V, ok bool) {
    	c.mu.Lock()
    	defer c.mu.Unlock()
    	if ent := c.evictList.Back(); ent != nil {
    		return ent.Key, ent.Value, true
    	}
    	return
    }
    
    Registered: Sun Sep 07 09:35:13 UTC 2025
    - Last Modified: Fri Apr 25 08:22:26 UTC 2025
    - 12.5K bytes
    - Viewed (0)
  2. tests/lru_test.go

    // }
    
    func TestLRUWithPurge(t *testing.T) {
    	var evicted []string
    	lc := lru.NewLRU(10, func(key string, value string) { evicted = append(evicted, key, value) }, 150*time.Millisecond)
    
    	k, v, ok := lc.GetOldest()
    	if k != "" {
    		t.Fatalf("should be empty")
    	}
    	if v != "" {
    		t.Fatalf("should be empty")
    	}
    	if ok {
    		t.Fatalf("should be false")
    	}
    
    	lc.Add("key1", "val1")
    
    Registered: Sun Sep 07 09:35:13 UTC 2025
    - Last Modified: Sun May 25 07:40:40 UTC 2025
    - 10.4K bytes
    - Viewed (0)
Back to top