protected EntityDA(IConfig config, ISqlStatementDA sqlStatementDA) : base(config)
 {
     if (!ServerCache.Exists(CacheKey.SqlStatement))
     {
         ServerCache.Add(CacheKey.SqlStatement, () => GetSqlStatementCallback(sqlStatementDA));
     }
 }
        public static int Main(string[] args)
        {
            if (!Directory.Exists(CACHE_DIR))
            {
                Directory.CreateDirectory(CACHE_DIR);
            }

            var compression = CompressedContent.Default()
                              .Level(CompressionLevel.Optimal);

            var cache = ServerCache.Persistent(CACHE_DIR)
                        .Invalidate(false);

            var project = Project.Create()
                          .Add(compression)
                          .Add(cache);

            var cachePolicy = ClientCache.Policy()
                              .Duration(7)
                              .Predicate((_, r) => r.ContentType?.KnownType != ContentType.TextHtml);

            return(Host.Create()
                   .Handler(project)
#if DEBUG
                   .Development()
#endif
                   .Add(cachePolicy)
                   .Defaults()
                   .Console()
                   .Run());
        }
Example #3
0
 public static void Configure()
 {
     ServerCache.Add(CacheKey.UserAccess, () => new UserDataCollection());
     ServerCache.Add(CacheKey.BranchConfig, BranchConfigCallback);
     ServerCache.Add(CacheKey.Message, MessageCallback);
     ServerCache.Add(CacheKey.Branding, BrandingCallback);
     ServerCache.Add(CacheKey.SystemInformation, SystemInformationCallback);
 }
		public void AddCachedStudy(StudyStorageLocation theLocation)
		{
			ServerCache<string, StudyStorageLocation> partitionCache;
			lock (_lock)
			{
				if (!_caches.TryGetValue(theLocation.ServerPartitionKey, out partitionCache))
				{
					partitionCache = new ServerCache<string, StudyStorageLocation>(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30));
					_caches.Add(theLocation.ServerPartitionKey,partitionCache);
				}
			}

			partitionCache.Add(theLocation.StudyInstanceUid, theLocation);
		}
Example #5
0
        public void AddCachedStudy(StudyStorageLocation theLocation)
        {
            ServerCache <string, StudyStorageLocation> partitionCache;

            lock (_lock)
            {
                if (!_caches.TryGetValue(theLocation.ServerPartitionKey, out partitionCache))
                {
                    partitionCache = new ServerCache <string, StudyStorageLocation>(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30));
                    _caches.Add(theLocation.ServerPartitionKey, partitionCache);
                }
            }

            partitionCache.Add(theLocation.StudyInstanceUid, theLocation);
        }
Example #6
0
        public void TestAdd_Get_Class_Success()
        {
            var tokenID = Guid.NewGuid();

            ServerCache.Add(key, () => new UserDataCollection {
                new UserData {
                    TokenID = tokenID
                }
            });

            var result = ServerCache.Get <UserDataCollection>(key);

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(tokenID, result[0].TokenID);
        }
Example #7
0
    void OnDestroy()
    {
        Printf("Destroy");

        if (CacheClient != null)
        {
            CacheClient.Destroy();
        }
        CacheClient = null;

        if (CacheServer != null)
        {
            CacheServer.Destroy();
        }

        CacheServer = null;
    }
Example #8
0
        private void listen(Action <Client> action)
        {
            Object obj;

            byte[] data;
            data = Util.Integrity.receiveAndConfirmMessageFromStream(connection);
            obj  = Util.Metadata.deserializeReadableObject(data, false);
            if (obj is Client)
            {
                client = (Client)obj;
                ServerCache.addClient(client);
                new Thread(() => action(client)).Start();
                Util.Integrity.sendObject(connection, Util.Integrity.nullCommand);
            }
            else
            {
                throw new Exception("Expected initial handshake, got " + obj.GetType());
            }
            while (connection.isConnected)
            {
                data = Util.Integrity.receiveAndConfirmMessageFromStream(connection);
                obj  = Util.Metadata.deserializeReadableObject(data, false);
                if (obj is Command)
                {
                    processCommand(obj);
                    if (client.commands.Count > 0)
                    {
                        Util.Integrity.sendObject(connection, client.commands.Dequeue());
                    }
                    else
                    {
                        Util.Integrity.sendObject(connection, Util.Integrity.nullCommand);
                    }
                }
                else
                {
                    Logger.addEntryToLog(this, "Invalid type!");
                }
            }
        }
 protected EntityRepository()
 {
     this.DataPortalLocation = DataPortalLocation.Dynamic;
     _clientCache            = new ClientCache(this);
     _serverCache            = new ServerCache(this);
 }
Example #10
0
 public void Initialize()
 {
     ServerCache.ClearCache();
     SynchronizedCacheManager.Instance = new SynchronizedCacheManager();
 }
Example #11
0
        public void TestAdd_Get_SimpleType_Success()
        {
            ServerCache.Add(key, () => "result");

            Assert.AreEqual("result", ServerCache.Get <string>(key));
        }
 /// <summary>
 /// 页面缓存
 /// </summary>
 /// <param name="server">服务缓存类型</param>
 /// <param name="browser">浏览器缓存类型</param>
 /// <param name="minutes">缓存时间</param>
 public PageCacheAttribute(ServerCache server, BrowserCache browser, int minutes)
 {
 }