MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / cmdGETRANGE

Function cmdGETRANGE

strings.go:219–255  ·  view source on GitHub ↗
(m uhaha.Machine, args []string)

Source from the content-addressed store, hash-verified

217 return v, nil
218}
219
220func cmdGETRANGE(m uhaha.Machine, args []string) (interface{}, error) {
221 // Check if the number of arguments is correct
222 if len(args) != 4 {
223 return nil, uhaha.ErrWrongNumArgs
224 }
225
226 key := []byte(args[1])
227
228 // Parse start index, returns error if not a valid integer
229 start, err := strconv.Atoi(args[2])
230 if err != nil {
231 return nil, err
232 }
233
234 // Parse end index, returns error if not a valid integer
235 end, err := strconv.Atoi(args[3])
236 if err != nil {
237 return nil, err
238 }
239
240 // Call underlying GetRange implementation
241 // Assumes ldb.GetRange handles:
242 // 1. Negative index conversion
243 // 2. Boundary checking
244 // 3. Non-existent key cases
245 v, err := ldb.GetRange(key, start, end)
246 if err != nil {
247 return nil, err
248 }
249
250 // Return empty string for nil value to match RESP behavior
251 if v == nil {
252 return "", nil
253 }
254
255 return v, nil
256}
257
258// cmdSETBIT sets or clears the bit at offset in the string value stored at key.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected