-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcache.go
43 lines (40 loc) · 1.21 KB
/
cache.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package gcache
type Value struct {
Exists bool
Value interface{}
}
type Cache interface {
// Add the value to the cache, only when the key does not exist
Add(key, value interface{}) (added bool)
// Put key value to cache
Put(key, value interface{})
// Get return cache value
Get(key interface{}) (value interface{}, exists bool)
// BatchPut pairs to cache
BatchPut(pair ...interface{})
// BatchGet return cache values
BatchGet(key ...interface{}) (vals []Value)
// Delete key from cache
Delete(key ...interface{}) (changed int)
// Len returns the number of cached data
Len() (count int)
// Clear all cached data
Clear()
}
// Low-level caching is usually only used when combining multiple caching algorithms
type LowCache interface {
// Clear Expired cache
ClearExpired()
// Add the value to the cache, only when the key does not exist
Add(key, value interface{}) (added bool)
// Put key value to cache
Put(key, value interface{}) (delkey, delval interface{}, deleted bool)
// Get return cache value
Get(key interface{}) (value interface{}, exists bool)
// Delete key from cache
Delete(key ...interface{}) (changed int)
// Len returns the number of cached data
Len() int
// Clear all cached data
Clear()
}