public async Task <StoredLatency> Delete(StreamEntityBase item, IStreamPersisterBatch batch = null) { double storedLatency = 0.0; if (batch != null) { RedisStreamPersisterBatch stx = batch as RedisStreamPersisterBatch; stx.AddItem(item, stx.Batch.HashDeleteAsync($"{_databaseName}-{item.EntityType}", item.Id)); storedLatency = 0.0; } else { await _db.HashDeleteAsync($"{_databaseName}-{item.EntityType}", item.Id); storedLatency = StreamEntityPersisterPartition.GetStoredLatency(item); } return(new StoredLatency { NumItems = (batch == null ? 1 : 0), Time = storedLatency }); }
public async Task <StoredLatency> Upsert(StreamEntityBase item, IStreamPersisterBatch batch = null) { double storedLatency = 0.0; var data = item.ToProtoBufByteArray(); if (batch != null) { RedisStreamPersisterBatch stx = batch as RedisStreamPersisterBatch; stx.AddItem(item, stx.Batch.HashSetAsync($"{_databaseName}-{item.EntityType}", item.Id, data)); storedLatency = 0.0; } else { await _db.HashSetAsync($"{_databaseName}-{item.EntityType}", item.Id, data); storedLatency = StreamEntityPersisterPartition.GetStoredLatency(item); } Interlocked.Increment(ref _numUpserts); return(new StoredLatency { NumItems = (batch == null ? 1 : 0), Time = storedLatency }); }