MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / Append

Method Append

structure/string.go:178–198  ·  view source on GitHub ↗

Append appends a value to the value of a key

(key string, v interface{}, ttl int64)

Source from the content-addressed store, hash-verified

176
177// Append appends a value to the value of a key
178func (s *StringStructure) Append(key string, v interface{}, ttl int64) error {
179 // Get the old value
180 oldValue, err := s.Get(key)
181 if err != nil {
182 return err
183 }
184
185 value, err, _ := interfaceToBytes(v)
186 if err != nil {
187 return err
188 }
189
190 // Convert the old value to a byte slice
191 oldValueType := []byte(oldValue.(string))
192
193 // Append the value
194 newValue := append(oldValueType, value...)
195
196 // Set the value
197 return s.Set(key, string(newValue), ttl)
198}
199
200// Incr increments the integer value of a key by 1
201func (s *StringStructure) Incr(key string, ttl int64) error {

Callers

nothing calls this directly

Calls 3

GetMethod · 0.95
SetMethod · 0.95
interfaceToBytesFunction · 0.85

Tested by

no test coverage detected