Exemple #1
0
        void ICacheStore.PurgeApplicationID(int appID)
        {
            var results = data
                          .Where(r => r.Key != null)
                          .Where(r => EntityID.GetApplicationID(r.Key) == appID);

            foreach (FileCacheRecord rec in results)
            {
                rec.RemoveLinkedFile();

                data.Remove(rec);
            }
        }
Exemple #2
0
        void ICacheStore.PurgeApplicationID(int appID)
        {
            var results = dc.ServerCache
                          .Where(r => r.Key != null)
                          .Select(r => r.Key)
                          .AsEnumerable()
                          .Where(k => EntityID.GetApplicationID(k.ToArray()) == appID);

            var records = dc.ServerCache
                          .Where(r => r.Key != null)
                          .Where(r => results.Contains(r.Key));

            foreach (DBCacheRecord rec in records)
            {
                rec.RemoveLinkedFile();
            }

            dc.ServerCache.DeleteAllOnSubmit(records);
            dc.SubmitChanges();
        }
Exemple #3
0
        public void UnpackDefinitions(List <FieldList> sources)
        {
            if ((sources != null) && (sources.Count > 0))
            {
                List <CacheDataTemplate> templates = new List <CacheDataTemplate>(sources.Count);

                foreach (FieldList source in sources)
                {
                    int appID = source[MessageOutFieldID.ApplicationID].AsInteger() ?? 0;
                    int defID = source[MessageOutFieldID.DefinitionID].AsInteger() ?? 0;

                    DefinitionBase liveEntity = CreateDefinition(source);

                    if (liveEntity != null)
                    {
                        // find cache item ID and cache hint
                        CacheItemID?ciid      = null;
                        byte        cacheHint = 0;

                        byte[] ciidData = source[MessageOutFieldID.CacheItemID].AsByteArray();

                        if (ciidData != null)
                        {
                            ciid = new CacheItemID(ciidData);

                            cacheHint = source[MessageOutFieldID.CacheHint].AsByte() ?? 0;
                        }

                        if (ciid.HasValue)
                        {
                            templates.Add(new CacheDataTemplate(liveEntity, ciid, EntityID.Create(CacheEntityType.Definition, appID, defID), CacheEntityType.Definition, cacheHint));
                        }
                    }
                }

                Core.Cache.Server.AddRange(templates, true);
            }
        }
Exemple #4
0
        public DefinitionBase Find(int applicationID, int definitionID, bool createIfNeeded = false)
        {
            byte[] entityID = EntityID.Create(CacheEntityType.Definition, applicationID, definitionID);
            object data     = Core.Cache.Server.FindLiveEntity(null, entityID);

            if (data == null)
            {
                data = Core.Cache.Server[entityID];
            }

            if (data != null)
            {
                if (data is DefinitionBase)
                {
                    return(data as DefinitionBase);
                }
                else if (createIfNeeded && (data is FieldList))
                {
                    return(UnpackDefinition((FieldList)data)); //TODO: cache this?
                }
            }

            return(null);
        }