示例#1
0
        public static async Task <IList <ICacheKey <TEntry> > > KeysAsync <TEntry>(this ICacheKey <TEntry> entry, Installation installation = Installation.Default)
            where TEntry : new()
        {
            Type keyType = entry.GetType();
            IList <ICacheKey <TEntry> > keys = new List <ICacheKey <TEntry> >();

            foreach (string key in await entry.Manager <ICacheKey <TEntry>, TEntry>().ListAsync(installation))
            {
                ICacheKey <TEntry>   multitonKey = (ICacheKey <TEntry>)Activator.CreateInstance(keyType);
                IEnumerator <string> keyValues   = PropertyValue(key);
                if (!keyValues.MoveNext())
                {
                    continue;
                }
                foreach (PropertyInfo property in keyType.FetchProperties(ICacheKey <TEntry> .CacheIgnore))
                {
                    property.SetValue(multitonKey, Convert.ChangeType(keyValues.Current, property.PropertyType));
                    if (!keyValues.MoveNext())
                    {
                        break;
                    }
                }
                keys.Add(multitonKey);
            }
            return(keys);
示例#2
0
 public static async Task <bool> RestoreAsync <TEntry>(this ICacheKey <TEntry> entry, TEntry value = default, TimeSpan expiringTime = default, Installation installation = Installation.Default)
     where TEntry : new()
 => await entry.Manager <ICacheKey <TEntry>, TEntry>().UpdateAsync(entry, value, expiringTime, installation).NoContext();
示例#3
0
 public static async Task <bool> IsPresentAsync <TEntry>(this ICacheKey <TEntry> entry, Installation installation = Installation.Default)
     where TEntry : new()
 => await entry.Manager <ICacheKey <TEntry>, TEntry>().ExistsAsync(entry, installation).NoContext();
示例#4
0
 public static async Task <TEntry> InstanceAsync <TEntry>(this ICacheKey <TEntry> entry, Installation installation = Installation.Default, bool withConsistency = false)
     where TEntry : new()
 => await entry.Manager <ICacheKey <TEntry>, TEntry>().InstanceAsync(entry, withConsistency, installation).NoContext();