From d8e1842d2507b2c18b21671ed01496b3a2c59e18 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 10 May 2009 12:27:05 +0000 Subject: Add some asset cache plumbing. Change the generic cache from UUID to string keys to allow caching the new crop of URI identified objects. --- OpenSim/Framework/Cache.cs | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Cache.cs b/OpenSim/Framework/Cache.cs index 3dab9b6..2d49146 100644 --- a/OpenSim/Framework/Cache.cs +++ b/OpenSim/Framework/Cache.cs @@ -33,8 +33,8 @@ namespace OpenSim.Framework { // The delegate we will use for performing fetch from backing store // - public delegate Object FetchDelegate(UUID index); - public delegate bool ExpireDelegate(UUID index); + public delegate Object FetchDelegate(string index); + public delegate bool ExpireDelegate(string index); // Strategy // @@ -64,14 +64,14 @@ namespace OpenSim.Framework } // The base class of all cache objects. Implements comparison and sorting - // by the UUID member. + // by the string member. // // This is not abstract because we need to instantiate it briefly as a // method parameter // public class CacheItemBase : IEquatable, IComparable { - public UUID uuid; + public string uuid; public DateTime entered; public DateTime lastUsed; public DateTime expires = new DateTime(0); @@ -86,14 +86,14 @@ namespace OpenSim.Framework { } - public CacheItemBase(UUID index) + public CacheItemBase(string index) { uuid = index; entered = DateTime.Now; lastUsed = entered; } - public CacheItemBase(UUID index, DateTime ttl) + public CacheItemBase(string index, DateTime ttl) { uuid = index; entered = DateTime.Now; @@ -123,23 +123,23 @@ namespace OpenSim.Framework { private Object m_Data; - public MemoryCacheItem(UUID index) : + public MemoryCacheItem(string index) : base(index) { } - public MemoryCacheItem(UUID index, DateTime ttl) : + public MemoryCacheItem(string index, DateTime ttl) : base(index, ttl) { } - public MemoryCacheItem(UUID index, Object data) : + public MemoryCacheItem(string index, Object data) : base(index) { Store(data); } - public MemoryCacheItem(UUID index, DateTime ttl, Object data) : + public MemoryCacheItem(string index, DateTime ttl, Object data) : base(index, ttl) { Store(data); @@ -160,23 +160,23 @@ namespace OpenSim.Framework // public class FileCacheItem : CacheItemBase { - public FileCacheItem(UUID index) : + public FileCacheItem(string index) : base(index) { } - public FileCacheItem(UUID index, DateTime ttl) : + public FileCacheItem(string index, DateTime ttl) : base(index, ttl) { } - public FileCacheItem(UUID index, Object data) : + public FileCacheItem(string index, Object data) : base(index) { Store(data); } - public FileCacheItem(UUID index, DateTime ttl, Object data) : + public FileCacheItem(string index, DateTime ttl, Object data) : base(index, ttl) { Store(data); @@ -200,8 +200,8 @@ namespace OpenSim.Framework public class Cache { private List m_Index = new List(); - private Dictionary m_Lookup = - new Dictionary(); + private Dictionary m_Lookup = + new Dictionary(); private CacheStrategy m_Strategy; private CacheMedium m_Medium; @@ -312,7 +312,7 @@ namespace OpenSim.Framework // Get an item from cache. Return the raw item, not it's data // - protected virtual CacheItemBase GetItem(UUID index) + protected virtual CacheItemBase GetItem(string index) { CacheItemBase item = null; @@ -339,7 +339,7 @@ namespace OpenSim.Framework // Get an item from cache. Do not try to fetch from source if not // present. Just return null // - public virtual Object Get(UUID index) + public virtual Object Get(string index) { CacheItemBase item = GetItem(index); @@ -352,7 +352,7 @@ namespace OpenSim.Framework // Fetch an object from backing store if not cached, serve from // cache if it is. // - public virtual Object Get(UUID index, FetchDelegate fetch) + public virtual Object Get(string index, FetchDelegate fetch) { Object item = Get(index); if (item != null) @@ -393,7 +393,7 @@ namespace OpenSim.Framework return item.Retrieve(); } - public virtual void Store(UUID index, Object data) + public virtual void Store(string index, Object data) { Type container; @@ -411,12 +411,12 @@ namespace OpenSim.Framework Store(index, data, container); } - public virtual void Store(UUID index, Object data, Type container) + public virtual void Store(string index, Object data, Type container) { Store(index, data, container, new Object[] { index }); } - public virtual void Store(UUID index, Object data, Type container, + public virtual void Store(string index, Object data, Type container, Object[] parameters) { Expire(false); @@ -520,7 +520,7 @@ namespace OpenSim.Framework } } - public void Invalidate(UUID uuid) + public void Invalidate(string uuid) { if (!m_Lookup.ContainsKey(uuid)) return; -- cgit v1.1