Skip to content

Commit 0bf2c5a

Browse files
committed
v0.0.3
1 parent eac040d commit 0bf2c5a

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ Returns `true` if the key exists, else returns `false`.
5757

5858
### 5. func (lru *HashLRU) Remove
5959
```go
60-
func (lru *HashLRU) Remove(key interface{}) (interface{}, bool)
60+
func (lru *HashLRU) Remove(key interface{}) bool
6161
```
6262

63-
Deletes the key-value pair and returns `deletedValue, true` if it exists, else returns `nil, false`.
63+
Deletes the key-value pair and returns `true` if it exists, else returns `false`.
6464

6565
### 6. func (lru *HashLRU) Len
6666
```go

example/example.go

+3
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ func main() {
2020
fmt.Println(numVal)
2121
// 5
2222

23+
fmt.Println(cache.Has(20))
24+
// true
25+
2326
}

hashlru.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,25 @@ func (lru *HashLRU) Has(key interface{}) bool {
9393
}
9494

9595
// Removes a key from the cache
96-
func (lru *HashLRU) Remove(key interface{}) (interface{}, bool) {
96+
func (lru *HashLRU) Remove(key interface{}) bool {
9797

9898
lru.lock.Lock()
9999

100-
if value, found := lru.newCache[key]; found {
100+
if _, found := lru.newCache[key]; found {
101101
delete(lru.newCache, key)
102102
lru.lock.Unlock()
103-
return value, true
103+
return true
104104
}
105105

106-
if value, found := lru.oldCache[key]; found {
106+
if _, found := lru.oldCache[key]; found {
107107
delete(lru.oldCache, key)
108108
lru.lock.Unlock()
109-
return value, true
109+
return true
110110
}
111111

112112
lru.lock.Unlock()
113113

114-
return nil, false
114+
return false
115115

116116
}
117117

0 commit comments

Comments
 (0)