CacheKey() 개인적인 정적인 메소드

private static CacheKey ( ) : string
리턴 string
예제 #1
0
        /// <summary>
        /// Returns Global Attributes from cache.  If they are not already in cache, they
        /// will be read and added to cache
        /// </summary>
        /// <returns></returns>
        public static GlobalAttributesCache Read()
        {
            string cacheKey = GlobalAttributesCache.CacheKey();

            ObjectCache           cache            = MemoryCache.Default;
            GlobalAttributesCache globalAttributes = cache[cacheKey] as GlobalAttributesCache;

            if (globalAttributes != null)
            {
                return(globalAttributes);
            }
            else
            {
                globalAttributes                 = new GlobalAttributesCache();
                globalAttributes.Attributes      = new List <AttributeCache>();
                globalAttributes.AttributeValues = new Dictionary <string, KeyValuePair <string, string> >();

                var attributeService      = new Rock.Model.AttributeService();
                var attributeValueService = new Rock.Model.AttributeValueService();

                foreach (Rock.Model.Attribute attribute in attributeService.GetGlobalAttributes())
                {
                    var attributeCache = AttributeCache.Read(attribute);
                    globalAttributes.Attributes.Add(attributeCache);

                    var    attributeValue = attributeValueService.GetByAttributeIdAndEntityId(attribute.Id, null).FirstOrDefault();
                    string value          = (attributeValue != null && !string.IsNullOrEmpty(attributeValue.Value)) ? attributeValue.Value : attributeCache.DefaultValue;
                    globalAttributes.AttributeValues.Add(attributeCache.Key, new KeyValuePair <string, string>(attributeCache.Name, value));
                }

                cache.Set(cacheKey, globalAttributes, new CacheItemPolicy());

                return(globalAttributes);
            }
        }
예제 #2
0
        /// <summary>
        /// Removes Global Attributes from cache
        /// </summary>
        public static void Flush()
        {
            _cache.Remove(GlobalAttributesCache.CacheKey());

            if (HttpContext.Current != null)
            {
                var appSettings = HttpContext.Current.Application;
                appSettings[ORG_LOC_GUID]    = null;
                appSettings[ORG_LOC_STATE]   = null;
                appSettings[ORG_LOC_COUNTRY] = null;
            }
        }
예제 #3
0
        /// <summary>
        /// Removes Global Attributes from cache
        /// </summary>
        public static void Flush()
        {
            ObjectCache cache = MemoryCache.Default;

            cache.Remove(GlobalAttributesCache.CacheKey());
        }
예제 #4
0
 /// <summary>
 /// Reads the specified rock context.
 /// </summary>
 /// <param name="rockContext">The rock context.</param>
 /// <returns></returns>
 public static GlobalAttributesCache Read(RockContext rockContext)
 {
     return(GetOrAddExisting(GlobalAttributesCache.CacheKey(),
                             () => Load(rockContext)));
 }