Skip to content

Commit ecee3be

Browse files
authoredJun 10, 2021
Fix typos, add doc (#78)
* Update lru.go fix typo * Update lfu.go Fix typo * Update arc.go Fix typo * fix typos. Add doc in the interface
1 parent a95af3e commit ecee3be

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed
 

‎arc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func (c *ARC) Get(key interface{}) (interface{}, error) {
172172
}
173173

174174
// GetIFPresent gets a value from cache pool using key if it exists.
175-
// If it dose not exists key, returns KeyNotFoundError.
175+
// If it does not exists key, returns KeyNotFoundError.
176176
// And send a request which refresh value for specified key if cache object has LoaderFunc.
177177
func (c *ARC) GetIFPresent(key interface{}) (interface{}, error) {
178178
v, err := c.get(key, false)

‎cache.go

+16
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,32 @@ const (
1717
var KeyNotFoundError = errors.New("Key not found.")
1818

1919
type Cache interface {
20+
// Set inserts or updates the specified key-value pair.
2021
Set(key, value interface{}) error
22+
// SetWithExpire inserts or updates the specified key-value pair with an expiration time.
2123
SetWithExpire(key, value interface{}, expiration time.Duration) error
24+
// Get returns the value for the specified key if it is present in the cache.
25+
// If the key is not present in the cache and the cache has LoaderFunc,
26+
// invoke the `LoaderFunc` function and inserts the key-value pair in the cache.
27+
// If the key is not present in the cache and the cache does not have a LoaderFunc,
28+
// return KeyNotFoundError.
2229
Get(key interface{}) (interface{}, error)
30+
// GetIFPresent returns the value for the specified key if it is present in the cache.
31+
// Return KeyNotFoundError if the key is not present.
2332
GetIFPresent(key interface{}) (interface{}, error)
33+
// GetAll returns a map containing all key-value pairs in the cache.
2434
GetALL(checkExpired bool) map[interface{}]interface{}
2535
get(key interface{}, onLoad bool) (interface{}, error)
36+
// Remove removes the specified key from the cache if the key is present.
37+
// Returns true if the key was present and the key has been deleted.
2638
Remove(key interface{}) bool
39+
// Purge removes all key-value pairs from the cache.
2740
Purge()
41+
// Keys returns a slice containing all keys in the cache.
2842
Keys(checkExpired bool) []interface{}
43+
// Len returns the number of items in the cache.
2944
Len(checkExpired bool) int
45+
// Has returns true if the key exists in the cache.
3046
Has(key interface{}) bool
3147

3248
statsAccessor

‎lfu.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (c *LFUCache) set(key, value interface{}) (interface{}, error) {
112112
}
113113

114114
// Get a value from cache pool using key if it exists.
115-
// If it dose not exists key and has LoaderFunc,
115+
// If it does not exists key and has LoaderFunc,
116116
// generate a value using `LoaderFunc` method returns value.
117117
func (c *LFUCache) Get(key interface{}) (interface{}, error) {
118118
v, err := c.get(key, false)
@@ -123,7 +123,7 @@ func (c *LFUCache) Get(key interface{}) (interface{}, error) {
123123
}
124124

125125
// GetIFPresent gets a value from cache pool using key if it exists.
126-
// If it dose not exists key, returns KeyNotFoundError.
126+
// If it does not exists key, returns KeyNotFoundError.
127127
// And send a request which refresh value for specified key if cache object has LoaderFunc.
128128
func (c *LFUCache) GetIFPresent(key interface{}) (interface{}, error) {
129129
v, err := c.get(key, false)

‎lru.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (c *LRUCache) SetWithExpire(key, value interface{}, expiration time.Duratio
8989
}
9090

9191
// Get a value from cache pool using key if it exists.
92-
// If it dose not exists key and has LoaderFunc,
92+
// If it does not exists key and has LoaderFunc,
9393
// generate a value using `LoaderFunc` method returns value.
9494
func (c *LRUCache) Get(key interface{}) (interface{}, error) {
9595
v, err := c.get(key, false)
@@ -100,7 +100,7 @@ func (c *LRUCache) Get(key interface{}) (interface{}, error) {
100100
}
101101

102102
// GetIFPresent gets a value from cache pool using key if it exists.
103-
// If it dose not exists key, returns KeyNotFoundError.
103+
// If it does not exists key, returns KeyNotFoundError.
104104
// And send a request which refresh value for specified key if cache object has LoaderFunc.
105105
func (c *LRUCache) GetIFPresent(key interface{}) (interface{}, error) {
106106
v, err := c.get(key, false)

‎simple.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (c *SimpleCache) set(key, value interface{}) (interface{}, error) {
8787
}
8888

8989
// Get a value from cache pool using key if it exists.
90-
// If it dose not exists key and has LoaderFunc,
90+
// If it does not exists key and has LoaderFunc,
9191
// generate a value using `LoaderFunc` method returns value.
9292
func (c *SimpleCache) Get(key interface{}) (interface{}, error) {
9393
v, err := c.get(key, false)
@@ -98,7 +98,7 @@ func (c *SimpleCache) Get(key interface{}) (interface{}, error) {
9898
}
9999

100100
// GetIFPresent gets a value from cache pool using key if it exists.
101-
// If it dose not exists key, returns KeyNotFoundError.
101+
// If it does not exists key, returns KeyNotFoundError.
102102
// And send a request which refresh value for specified key if cache object has LoaderFunc.
103103
func (c *SimpleCache) GetIFPresent(key interface{}) (interface{}, error) {
104104
v, err := c.get(key, false)

0 commit comments

Comments
 (0)