diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs index ebec9d2..403236c 100644 --- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs | |||
@@ -41,16 +41,16 @@ namespace OpenSim.Region.CoreModules.Asset | |||
41 | /// </summary> | 41 | /// </summary> |
42 | /// <remarks> | 42 | /// <remarks> |
43 | /// <para> | 43 | /// <para> |
44 | /// Cache is enabled by setting "AssetCaching" configuration to value "CenomeMemoryAssetCache". | 44 | /// Cache is enabled by setting "AssetCaching" configuration to value "CenomeMemoryAssetCache". |
45 | /// When cache is successfully enable log should have message | 45 | /// When cache is successfully enable log should have message |
46 | /// "[ASSET CACHE]: Cenome asset cache enabled (MaxSize = XXX bytes, MaxCount = XXX, ExpirationTime = XXX)". | 46 | /// "[ASSET CACHE]: Cenome asset cache enabled (MaxSize = XXX bytes, MaxCount = XXX, ExpirationTime = XXX)". |
47 | /// </para> | 47 | /// </para> |
48 | /// <para> | 48 | /// <para> |
49 | /// Cache's size is limited by two parameters: | 49 | /// Cache's size is limited by two parameters: |
50 | /// maximal allowed size in bytes and maximal allowed asset count. When new asset | 50 | /// maximal allowed size in bytes and maximal allowed asset count. When new asset |
51 | /// is added to cache that have achieved either size or count limitation, cache | 51 | /// is added to cache that have achieved either size or count limitation, cache |
52 | /// will automatically remove less recently used assets from cache. Additionally | 52 | /// will automatically remove less recently used assets from cache. Additionally |
53 | /// asset's lifetime is controlled by expiration time. | 53 | /// asset's lifetime is controlled by expiration time. |
54 | /// </para> | 54 | /// </para> |
55 | /// <para> | 55 | /// <para> |
56 | /// <list type="table"> | 56 | /// <list type="table"> |
@@ -91,10 +91,10 @@ namespace OpenSim.Region.CoreModules.Asset | |||
91 | /// </code> | 91 | /// </code> |
92 | /// </example> | 92 | /// </example> |
93 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "CenomeMemoryAssetCache")] | 93 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "CenomeMemoryAssetCache")] |
94 | public class CenomeMemoryAssetCache : IImprovedAssetCache, ISharedRegionModule | 94 | public class CenomeMemoryAssetCache : IAssetCache, ISharedRegionModule |
95 | { | 95 | { |
96 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 96 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
97 | 97 | ||
98 | /// <summary> | 98 | /// <summary> |
99 | /// Cache's default maximal asset count. | 99 | /// Cache's default maximal asset count. |
100 | /// </summary> | 100 | /// </summary> |
@@ -119,7 +119,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
119 | /// Asset's default expiration time in the cache. | 119 | /// Asset's default expiration time in the cache. |
120 | /// </summary> | 120 | /// </summary> |
121 | public static readonly TimeSpan DefaultExpirationTime = TimeSpan.FromMinutes(30.0); | 121 | public static readonly TimeSpan DefaultExpirationTime = TimeSpan.FromMinutes(30.0); |
122 | 122 | ||
123 | /// <summary> | 123 | /// <summary> |
124 | /// Cache object. | 124 | /// Cache object. |
125 | /// </summary> | 125 | /// </summary> |
@@ -192,7 +192,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
192 | expirationTime); | 192 | expirationTime); |
193 | } | 193 | } |
194 | 194 | ||
195 | #region IImprovedAssetCache Members | 195 | #region IAssetCache Members |
196 | 196 | ||
197 | public bool Check(string id) | 197 | public bool Check(string id) |
198 | { | 198 | { |
@@ -213,7 +213,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
213 | if (asset != null) | 213 | if (asset != null) |
214 | { | 214 | { |
215 | // m_log.DebugFormat("[CENOME ASSET CACHE]: Caching asset {0}", asset.ID); | 215 | // m_log.DebugFormat("[CENOME ASSET CACHE]: Caching asset {0}", asset.ID); |
216 | 216 | ||
217 | long size = asset.Data != null ? asset.Data.Length : 1; | 217 | long size = asset.Data != null ? asset.Data.Length : 1; |
218 | m_cache.Set(asset.ID, asset, size); | 218 | m_cache.Set(asset.ID, asset, size); |
219 | m_cachedCount++; | 219 | m_cachedCount++; |
@@ -221,6 +221,11 @@ namespace OpenSim.Region.CoreModules.Asset | |||
221 | 221 | ||
222 | } | 222 | } |
223 | 223 | ||
224 | public void CacheNegative(string id) | ||
225 | { | ||
226 | // We don't do negative caching | ||
227 | } | ||
228 | |||
224 | /// <summary> | 229 | /// <summary> |
225 | /// Clear asset cache. | 230 | /// Clear asset cache. |
226 | /// </summary> | 231 | /// </summary> |
@@ -241,7 +246,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
241 | } | 246 | } |
242 | 247 | ||
243 | /// <summary> | 248 | /// <summary> |
244 | /// Get asset stored | 249 | /// Get asset stored |
245 | /// </summary> | 250 | /// </summary> |
246 | /// <param name="id"> | 251 | /// <param name="id"> |
247 | /// The asset's id. | 252 | /// The asset's id. |
@@ -255,10 +260,9 @@ namespace OpenSim.Region.CoreModules.Asset | |||
255 | /// Cache doesn't guarantee in any situation that asset is stored to it. | 260 | /// Cache doesn't guarantee in any situation that asset is stored to it. |
256 | /// </para> | 261 | /// </para> |
257 | /// </remarks> | 262 | /// </remarks> |
258 | public AssetBase Get(string id) | 263 | public bool Get(string id, out AssetBase assetBase) |
259 | { | 264 | { |
260 | m_getCount++; | 265 | m_getCount++; |
261 | AssetBase assetBase; | ||
262 | if (m_cache.TryGetValue(id, out assetBase)) | 266 | if (m_cache.TryGetValue(id, out assetBase)) |
263 | m_hitCount++; | 267 | m_hitCount++; |
264 | 268 | ||
@@ -278,8 +282,8 @@ namespace OpenSim.Region.CoreModules.Asset | |||
278 | 282 | ||
279 | // if (null == assetBase) | 283 | // if (null == assetBase) |
280 | // m_log.DebugFormat("[CENOME ASSET CACHE]: Asset {0} not in cache", id); | 284 | // m_log.DebugFormat("[CENOME ASSET CACHE]: Asset {0} not in cache", id); |
281 | 285 | ||
282 | return assetBase; | 286 | return true; |
283 | } | 287 | } |
284 | 288 | ||
285 | #endregion | 289 | #endregion |
@@ -294,7 +298,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
294 | get { return "CenomeMemoryAssetCache"; } | 298 | get { return "CenomeMemoryAssetCache"; } |
295 | } | 299 | } |
296 | 300 | ||
297 | public Type ReplaceableInterface | 301 | public Type ReplaceableInterface |
298 | { | 302 | { |
299 | get { return null; } | 303 | get { return null; } |
300 | } | 304 | } |
@@ -308,7 +312,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
308 | public void AddRegion(Scene scene) | 312 | public void AddRegion(Scene scene) |
309 | { | 313 | { |
310 | if (m_enabled) | 314 | if (m_enabled) |
311 | scene.RegisterModuleInterface<IImprovedAssetCache>(this); | 315 | scene.RegisterModuleInterface<IAssetCache>(this); |
312 | } | 316 | } |
313 | 317 | ||
314 | /// <summary> | 318 | /// <summary> |
@@ -344,7 +348,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
344 | 348 | ||
345 | if (name != Name) | 349 | if (name != Name) |
346 | return; | 350 | return; |
347 | 351 | ||
348 | long maxSize = DefaultMaxSize; | 352 | long maxSize = DefaultMaxSize; |
349 | int maxCount = DefaultMaxCount; | 353 | int maxCount = DefaultMaxCount; |
350 | TimeSpan expirationTime = DefaultExpirationTime; | 354 | TimeSpan expirationTime = DefaultExpirationTime; |