SetRange overwrites part of the string stored at key, starting at the specified offset, for the entire length of value.
(offset int64, value []byte)
| 137 | |
| 138 | // SetRange overwrites part of the string stored at key, starting at the specified offset, for the entire length of value. |
| 139 | func (s *String) SetRange(offset int64, value []byte) ([]byte, error) { |
| 140 | val := s.Meta.Value |
| 141 | if int64(len(val)) < offset+int64(len(value)) { |
| 142 | val = append(val, make([]byte, offset+int64(len(value))-int64(len(val)))...) |
| 143 | } |
| 144 | copy(val[offset:], value) |
| 145 | if err := s.Set(val); err != nil { |
| 146 | return nil, err |
| 147 | } |
| 148 | |
| 149 | return val, nil |
| 150 | } |
| 151 | |
| 152 | // Incr increments the integer value by the given amount |
| 153 | // the old value must be integer |