private void updateCache(string uuid, string url, int cacheValidity) { YSSDPCacheEntry entry; if (cacheValidity <= 0) { cacheValidity = 1800; } cacheValidity *= 1000; if (_cache.ContainsKey(uuid)) { entry = _cache[uuid]; if (!entry.URL.Equals(url)) { _callbacks.HubDiscoveryCallback(entry.Serial, url, entry.URL); entry.URL = url; } else { _callbacks.HubDiscoveryCallback(entry.Serial, url, null); } entry.resetExpiration(cacheValidity); return; } entry = new YSSDPCacheEntry(uuid, url, cacheValidity); _cache[uuid] = entry; _callbacks.HubDiscoveryCallback(entry.Serial, entry.URL, null); }
private void checkCacheExpiration() { List<string> to_remove = new List<string>(); foreach (YSSDPCacheEntry entry in _cache.Values) { if (entry.hasExpired()) { _callbacks.HubDiscoveryCallback(entry.Serial, null, entry.URL); to_remove.Add(entry.UUID); } } foreach (string uuid in to_remove) { _cache.Remove(uuid); } }