-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.go
56 lines (49 loc) · 1.07 KB
/
interface.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
44
45
46
47
48
49
50
51
52
53
54
55
56
package fooche
import "time"
type ICache interface {
// Adds an element to cache.
//
// # Params
// - k: object key.
// - v: object value.
//
// # Returns
//
// An error if something goes wrong.
Set(k string, v []byte, ttl time.Duration) error
// Checks if an element is in cache.
//
// # Params
// - k: object key.
//
// # Returns
//
// Boolean indicating wether or not the object is present.
Has(k string) bool
// Gets an element from cache.
//
// # Params
// - k: object key.
//
// # Returns
//
// The object value and an error if anything goes wrong.
Get(k string) (v []byte, err error)
// Gets an element from cache.
//
// # Params
// - k: object key.
// - computeValue: function to compute the value if it's not present in cache.
//
// # Returns
//
// The object value and an error if anything goes wrong.
ComputeIfAbsent(k string, computeValue func() []byte) (v []byte, err error)
// Removes an element from cache.
//
// # Params
// - k: object key.
Delete(k string)
// Returns a string representation of the cache.
String() string
}