Get gets the value of a key If the key does not exist, it will return nil If the key exists, it will return the value If the key is expired, it will be deleted and return nil If the key is not expired, it will be updated and return the value
(k string)
| 76 | // If the key is expired, it will be deleted and return nil |
| 77 | // If the key is not expired, it will be updated and return the value |
| 78 | func (s *StringStructure) Get(k string) (interface{}, error) { |
| 79 | key := stringToBytesWithKey(k) |
| 80 | |
| 81 | // Get the value |
| 82 | value, err := s.db.Get(key) |
| 83 | if err != nil { |
| 84 | return nil, err |
| 85 | } |
| 86 | |
| 87 | interValue, _, err := decodeStringValue(value) |
| 88 | if err != nil { |
| 89 | return nil, err |
| 90 | } |
| 91 | |
| 92 | valueType := s.valueType |
| 93 | |
| 94 | valueToInterface, err := byteToInterface(interValue, valueType) |
| 95 | if err != nil { |
| 96 | return nil, err |
| 97 | } |
| 98 | |
| 99 | return valueToInterface, nil |
| 100 | } |
| 101 | |
| 102 | // Del deletes the value of a key |
| 103 | // If the key does not exist, it will return nil |
no test coverage detected