-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkeys.go
46 lines (36 loc) · 816 Bytes
/
keys.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
package redis3
import (
"reflect"
"time"
)
// Unlock TBD
func (c *Client) Unlock(key string) error {
return c.unlockKey(key)
}
// Lock TBD
func (c *Client) Lock(key string) error {
return c.lockKey(key)
}
// Del TBD
func (c *Client) Del(key string) error {
return c.deleteKey(key)
}
// Get TBD
func (c *Client) Get(key string, value interface{}) (KeyMetadata, error) {
metadata, err := c.downloadKey(key, value)
return metadata, err
}
// Set TBD
func (c *Client) Set(key string, value interface{}, expiration int64) error {
var expireTime int64
now := time.Now()
if expiration > 0 {
expireTime = now.Unix() + expiration
}
metadata := KeyMetadata{
ValueType: reflect.TypeOf(value).String(),
ExpireTime: expireTime,
LastUpdate: now.Unix(),
}
return c.uploadKey(key, value, metadata)
}