private void unregisterRepository(Key location) { WeakReference<Repository> oldRef = cacheMap.GetValue(location); cacheMap.Remove(location); Repository oldDb = oldRef != null ? oldRef.get() : null; if (oldDb != null) oldDb.Close(); }