Open pairbit opened 1 year ago
Usually, this command is used in tandem with KeyDump, so you'd also want parity there. What's the scenario where this would be useful? For example, for StringGet there is a lease-based overload. One option here might be to add a lease-based KeyDump, which could then meaningfully be used with KeyRestore. However, I'm curious as to what your scenario is where you want a non-vector payload.
I have developed program to restore a backup from file. I need to recover many keys. I would like to avoid multiple memory allocation for the byte array of the value. I want to replace "new byte[]" with using buffer or ArrayPool.
Code example as of now:
var value = new byte[valueSize];
await stream.ReadAsync(value, 0, valueSize);
await db.KeyRestoreAsync(key, value);
How I would like:
var rented = ArrayPool<byte>.Shared.Rent(valueSize);
var rentedMemory = rented.AsMemory(0, valueSize);
await stream.ReadAsync(rentedMemory);
await db.KeyRestoreAsync(key, rentedMemory);
ArrayPool<byte>.Shared.Return(rented);
Change please type byte[] value
from
void KeyRestore(RedisKey key, byte[] value, TimeSpan? expiry = null, CommandFlags flags = CommandFlags.None) Task KeyRestoreAsync(RedisKey key, byte[] value, TimeSpan? expiry = null, CommandFlags flags = CommandFlags.None)
to
void KeyRestore(RedisKey key, ReadOnlyMemory value, TimeSpan? expiry = null, CommandFlags flags = CommandFlags.None)
Task KeyRestoreAsync(RedisKey key, ReadOnlyMemory value, TimeSpan? expiry = null, CommandFlags flags = CommandFlags.None)