public bool TryGetValue(string key, out object val) { CacheItem item = backend.Get(key); if (item == null) { val = null; return(false); } else { val = item.Value; return(true); } }
public CacheItem Get(string key) { CacheItem ci = null; if (data.TryGetValue(key, out ci)) { Touch(ci); return(ci); } if (fallback != null) { // if the fallback contains the data, // bring it into our cache ci = fallback.Get(key); if (ci != null) { this.Set(ci); } } return(null); }
public CacheItem Get(string key) { FileEntry entry; CacheItem ci; if (data.TryGetValue(key, out entry) == false) { // not found, maybe the fallback has it? if (fallback != null) { ci = fallback.Get(key); if (ci != null) { Set(ci); } return(ci); } else { return(null); } } ci = entry.item; if (ci == null) // not still in memory { // lock the entry so that it wont get moved during Compact lock (entry) { // read from disk.. ci = Deserialize(entry); } } return(ci); }