aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Cache.cs
diff options
context:
space:
mode:
authorMelanie Thielker2008-08-13 12:20:49 +0000
committerMelanie Thielker2008-08-13 12:20:49 +0000
commit4b6097756f1295e65b4c732606f14f4b43d12fb6 (patch)
treea85cdade5d9df681c220b9114218dc7ac847ecf0 /OpenSim/Framework/Cache.cs
parentFrom: Omar Vera Ustariz <ustariz@de.ibm.com> (diff)
downloadopensim-SC-4b6097756f1295e65b4c732606f14f4b43d12fb6.zip
opensim-SC-4b6097756f1295e65b4c732606f14f4b43d12fb6.tar.gz
opensim-SC-4b6097756f1295e65b4c732606f14f4b43d12fb6.tar.bz2
opensim-SC-4b6097756f1295e65b4c732606f14f4b43d12fb6.tar.xz
Port the llParcelMediaQuery forward to the new Shared/ directory
Add a Dictionary for faster lookup of cached items.
Diffstat (limited to 'OpenSim/Framework/Cache.cs')
-rw-r--r--OpenSim/Framework/Cache.cs30
1 files changed, 24 insertions, 6 deletions
diff --git a/OpenSim/Framework/Cache.cs b/OpenSim/Framework/Cache.cs
index 780e262..7a1d682 100644
--- a/OpenSim/Framework/Cache.cs
+++ b/OpenSim/Framework/Cache.cs
@@ -173,6 +173,8 @@ namespace Opensim.Framework
173 public class Cache 173 public class Cache
174 { 174 {
175 private List<CacheItemBase> m_Index = new List<CacheItemBase>(); 175 private List<CacheItemBase> m_Index = new List<CacheItemBase>();
176 private Dictionary<LLUUID, CacheItemBase> m_Lookup =
177 new Dictionary<LLUUID, CacheItemBase>();
176 178
177 private CacheStrategy m_Strategy; 179 private CacheStrategy m_Strategy;
178 private CacheMedium m_Medium; 180 private CacheMedium m_Medium;
@@ -267,6 +269,11 @@ namespace Opensim.Framework
267 269
268 m_Index.RemoveRange(newSize, Count - newSize); 270 m_Index.RemoveRange(newSize, Count - newSize);
269 m_Size = newSize; 271 m_Size = newSize;
272
273 m_Lookup.Clear();
274
275 foreach (CacheItemBase item in m_Index)
276 m_Lookup[item.uuid] = item;
270 } 277 }
271 } 278 }
272 279
@@ -284,12 +291,8 @@ namespace Opensim.Framework
284 291
285 lock (m_Index) 292 lock (m_Index)
286 { 293 {
287 item = m_Index.Find(delegate(CacheItemBase i) 294 if(m_Lookup.ContainsKey(index))
288 { 295 item = m_Lookup[index];
289 if (i.uuid == index)
290 return true;
291 return false;
292 });
293 } 296 }
294 297
295 if (item == null) 298 if (item == null)
@@ -337,7 +340,10 @@ namespace Opensim.Framework
337 { 340 {
338 CacheItemBase missing = new CacheItemBase(index); 341 CacheItemBase missing = new CacheItemBase(index);
339 if (!m_Index.Contains(missing)) 342 if (!m_Index.Contains(missing))
343 {
340 m_Index.Add(missing); 344 m_Index.Add(missing);
345 m_Lookup[index] = missing;
346 }
341 } 347 }
342 } 348 }
343 return null; 349 return null;
@@ -404,6 +410,7 @@ namespace Opensim.Framework
404 item.expires = DateTime.Now + m_DefaultTTL; 410 item.expires = DateTime.Now + m_DefaultTTL;
405 411
406 m_Index.Add(item); 412 m_Index.Add(item);
413 m_Lookup[index] = item;
407 } 414 }
408 item.Store(data); 415 item.Store(data);
409 } 416 }
@@ -421,7 +428,10 @@ namespace Opensim.Framework
421 { 428 {
422 if (item.expires.Ticks == 0 || 429 if (item.expires.Ticks == 0 ||
423 item.expires <= now) 430 item.expires <= now)
431 {
424 m_Index.Remove(item); 432 m_Index.Remove(item);
433 m_Lookup.Remove(item.uuid);
434 }
425 } 435 }
426 } 436 }
427 437
@@ -450,12 +460,20 @@ namespace Opensim.Framework
450 foreach (CacheItemBase i in candidates) 460 foreach (CacheItemBase i in candidates)
451 { 461 {
452 if (doExpire(i.uuid)) 462 if (doExpire(i.uuid))
463 {
453 m_Index.Remove(i); 464 m_Index.Remove(i);
465 m_Lookup.Remove(i.uuid);
466 }
454 } 467 }
455 } 468 }
456 else 469 else
457 { 470 {
458 m_Index.RemoveRange(target, Count - target); 471 m_Index.RemoveRange(target, Count - target);
472
473 m_Lookup.Clear();
474
475 foreach (CacheItemBase item in m_Index)
476 m_Lookup[item.uuid] = item;
459 } 477 }
460 } 478 }
461 break; 479 break;