public async Task BasicTest() { IDbStore columnFamilyDbStore = this.rocksDbStoreProvider.GetColumnStoreFamily("test"); string key = "key1"; string value = "value1"; byte[] keyBytes = key.ToBytes(); byte[] valueBytes = value.ToBytes(); await columnFamilyDbStore.Put(keyBytes, valueBytes); Option <byte[]> returnedValueBytesOption = await columnFamilyDbStore.Get(keyBytes); Assert.True(returnedValueBytesOption.HasValue); byte[] returnedValueBytes = returnedValueBytesOption.OrDefault(); Assert.True(valueBytes.SequenceEqual(returnedValueBytes)); Assert.Equal(value, returnedValueBytes.FromBytes()); Assert.True(await columnFamilyDbStore.Contains(keyBytes)); Assert.False(await columnFamilyDbStore.Contains("key2".ToBytes())); await columnFamilyDbStore.Remove(keyBytes); returnedValueBytesOption = await columnFamilyDbStore.Get(keyBytes); Assert.False(returnedValueBytesOption.HasValue); }
public async Task GetRemoveDefaultPartitionTestAsync() { var options = new RocksDbOptionsProvider(new SystemEnvironment(), true); var partitionsList = new[] { "Partition1" }; using (IDbStoreProvider rocksDbStoreProvider = DbStoreProvider.Create(options, this.rocksDbFolder, partitionsList)) { Assert.NotNull(rocksDbStoreProvider); IDbStore store = rocksDbStoreProvider.GetDbStore(); string key = "key"; string val = "val"; byte[] valBytes = val.ToBytes(); await store.Put(key.ToBytes(), valBytes); Option <byte[]> valRetrieved = await store.Get("key".ToBytes()); byte[] valRetrievedBytes = valRetrieved.GetOrElse(string.Empty.ToBytes()); Assert.True(valRetrievedBytes.SequenceEqual(valBytes)); } }
public Task <TRole> FindByIdAsync(string roleId, CancellationToken cancellationToken = new CancellationToken()) { cancellationToken.ThrowIfCancellationRequested(); if (roleId == null) { throw new ArgumentNullException(nameof(roleId)); } return(Task.FromResult(_dbStore.Get <TRole>(ConvertIdFromString(roleId)))); }
public static T GetIf <T>(this IDbStore dbStore, object id) where T : IEntity { return(id == null ? default(T) : dbStore.Get <T>(id)); }
public T Get <T>(object id) where T : IEntity { return(_dbStore.Get <T>(id)); }