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()); }
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); }
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); }
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); }
void OnDestroy() { Printf("Destroy"); if (CacheClient != null) { CacheClient.Destroy(); } CacheClient = null; if (CacheServer != null) { CacheServer.Destroy(); } CacheServer = null; }
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); }
public void Initialize() { ServerCache.ClearCache(); SynchronizedCacheManager.Instance = new SynchronizedCacheManager(); }
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) { }