Method: Redis::Connection::Memory#ltrim
- Defined in:
- lib/redis/connection/memory.rb
#ltrim(key, start, stop) ⇒ Object
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
# File 'lib/redis/connection/memory.rb', line 388 def ltrim(key, start, stop) data_type_check(key, Array) return unless data[key] # Example: we have a list of 3 elements and # we give it a ltrim list, -5, -1. This means # it should trim to a max of 5. Since 3 < 5 # we should not touch the list. This is consistent # with behavior of real Redis's ltrim with a negative # start argument. unless start < 0 && data[key].count < start.abs data[key] = data[key][start..stop] end "OK" end |