Exemple #1
0
        internal static async Task <List <string> > GetSetCacheKeysAsync(IFilterBy <Portlet> filter, CancellationToken cancellationToken = default)
        {
            var desktopIDs = new List <string>();
            var portlets   = await Portlet.FindAsync(filter, null, 0, 1, null, cancellationToken).ConfigureAwait(false);

            await portlets.ForEachAsync(async portlet =>
            {
                var mappingPortlets = await Portlet.FindAsync(Filters <Portlet> .Equals("OriginalPortletID", portlet.ID), null, 0, 1, null, cancellationToken).ConfigureAwait(false);
                desktopIDs          = desktopIDs.Concat(new[] { portlet.DesktopID }).Concat(mappingPortlets.Select(mappingPortlet => mappingPortlet.DesktopID)).ToList();
            }, true, false).ConfigureAwait(false);

            var desktops = new List <Desktop>();
            await desktopIDs.Where(desktopID => !string.IsNullOrWhiteSpace(desktopID) && desktopID.IsValidUUID()).Distinct(StringComparer.OrdinalIgnoreCase).ToList().ForEachAsync(async desktopID =>
            {
                var desktop = await desktopID.GetDesktopByIDAsync(cancellationToken).ConfigureAwait(false);
                if (desktop != null)
                {
                    desktops.Add(desktop);
                }
            }, true, false).ConfigureAwait(false);

            return(desktops.Select(desktop => desktop.GetSetCacheKey()).ToList());
        }
Exemple #2
0
 /// <summary>
 /// Sets cache of page-size (to clear related cached further)
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="filter"></param>
 /// <param name="sort"></param>
 /// <param name="pageSize"></param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public static Task SetCacheOfPageSizeAsync <T>(IFilterBy <T> filter, SortBy <T> sort, int pageSize, CancellationToken cancellationToken = default) where T : class
 => Utility.Cache.SetAsync($"{Extensions.GetCacheKey(filter, sort)}:size", pageSize, cancellationToken);