public static async Task <DatabaseGetAsyncResult <T> > TryGetAsync <T>(this IDatabase database, object key)
        {
            if (database == null)
            {
                throw new ArgumentNullException(nameof(database));
            }
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            DatabaseGetAsyncResult result = await database.TryGetAsync(key);

            return(result.HasValue
                ? new DatabaseGetAsyncResult <T>((T)result.Value)
                : new DatabaseGetAsyncResult <T>());
        }
Exemplo n.º 2
0
        public async Task <object> GetAsync(object key)
        {
            DatabaseGetAsyncResult result = await TryGetAsync(key);

            return(result.HasValue ? result.Value : throw new ArgumentException($"Value not found by the specified key: '{key}'."));
        }
 public bool Equals(DatabaseGetAsyncResult <TValue> other)
 {
     return(EqualityComparer <TValue> .Default.Equals(m_value, other.m_value));
 }