StrLen returns the length of the value of a key If the key does not exist, it will return 0 If the key exists, it will return the length of the value If the key is expired, it will be deleted and return 0 If the key is not expired, it will be updated and return the length of the value
(k string)
| 139 | // If the key is expired, it will be deleted and return 0 |
| 140 | // If the key is not expired, it will be updated and return the length of the value |
| 141 | func (s *StringStructure) StrLen(k string) (int, error) { |
| 142 | key := stringToBytesWithKey(k) |
| 143 | // Get the value |
| 144 | value, err := s.db.Get(key) |
| 145 | if err != nil { |
| 146 | return 0, err |
| 147 | } |
| 148 | |
| 149 | // Decode the value |
| 150 | value, _, err = decodeStringValue(value) |
| 151 | if err != nil { |
| 152 | return 0, err |
| 153 | } |
| 154 | |
| 155 | // Return the length of the value |
| 156 | return len(value), nil |
| 157 | } |
| 158 | |
| 159 | // GetSet sets the value of a key and returns its old value |
| 160 | func (s *StringStructure) GetSet(key string, value interface{}, ttl int64) (interface{}, error) { |
nothing calls this directly
no test coverage detected