private void deleteOldest() { lock (cacheLock) { while (hashtable.Count >= CACHE_SIZE) { CasheLine line = (CasheLine)queue.Dequeue(); hashtable.Remove(line.key); } } }
public List <Trip> getDataFromCache(String query) { CasheLine result = null; String key = query; lock (cacheLock) { if (!hashtable.ContainsKey(key)) { return(null); } result = (CasheLine)hashtable[key]; } return(result.trips); }
public void insert(string query, List <Trip> tripList) { CasheLine line = new CasheLine(); line.key = query; line.trips = tripList; lock (cacheLock) { if (hashtable.Count >= CACHE_SIZE) { deleteOldest(); } hashtable.Add(query, line); queue.Enqueue(line); } }