diff options
author | Jeff Ames | 2009-06-09 18:07:35 +0000 |
---|---|---|
committer | Jeff Ames | 2009-06-09 18:07:35 +0000 |
commit | a7fcacf8f396acbca0b640a65acfbf5487d513e7 (patch) | |
tree | 5ba66f5c83eceeb81e24a0540ae4fac9847e0c78 /OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs | |
parent | Update svn properties. (diff) | |
download | opensim-SC_OLD-a7fcacf8f396acbca0b640a65acfbf5487d513e7.zip opensim-SC_OLD-a7fcacf8f396acbca0b640a65acfbf5487d513e7.tar.gz opensim-SC_OLD-a7fcacf8f396acbca0b640a65acfbf5487d513e7.tar.bz2 opensim-SC_OLD-a7fcacf8f396acbca0b640a65acfbf5487d513e7.tar.xz |
Formatting cleanup. Ignore some generated files.
Diffstat (limited to 'OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs index 5e3d243..d42c9e2 100644 --- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs | |||
@@ -114,12 +114,12 @@ namespace OpenSim.Region.CoreModules.Asset | |||
114 | /// <summary> | 114 | /// <summary> |
115 | /// Asset's default expiration time in the cache. | 115 | /// Asset's default expiration time in the cache. |
116 | /// </summary> | 116 | /// </summary> |
117 | public static readonly TimeSpan DefaultExpirationTime = TimeSpan.FromMinutes( 30.0 ); | 117 | public static readonly TimeSpan DefaultExpirationTime = TimeSpan.FromMinutes(30.0); |
118 | 118 | ||
119 | /// <summary> | 119 | /// <summary> |
120 | /// Log manager instance. | 120 | /// Log manager instance. |
121 | /// </summary> | 121 | /// </summary> |
122 | private static readonly ILog Log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType ); | 122 | private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
123 | 123 | ||
124 | /// <summary> | 124 | /// <summary> |
125 | /// Cache object. | 125 | /// Cache object. |
@@ -159,7 +159,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
159 | /// </summary> | 159 | /// </summary> |
160 | public void Initialize() | 160 | public void Initialize() |
161 | { | 161 | { |
162 | Initialize( DefaultMaxSize, DefaultMaxCount, DefaultExpirationTime ); | 162 | Initialize(DefaultMaxSize, DefaultMaxCount, DefaultExpirationTime); |
163 | } | 163 | } |
164 | 164 | ||
165 | /// <summary> | 165 | /// <summary> |
@@ -174,16 +174,16 @@ namespace OpenSim.Region.CoreModules.Asset | |||
174 | /// <param name="expirationTime"> | 174 | /// <param name="expirationTime"> |
175 | /// Asset's expiration time. | 175 | /// Asset's expiration time. |
176 | /// </param> | 176 | /// </param> |
177 | public void Initialize( long maximalSize, int maximalCount, TimeSpan expirationTime ) | 177 | public void Initialize(long maximalSize, int maximalCount, TimeSpan expirationTime) |
178 | { | 178 | { |
179 | if( maximalSize <= 0 || maximalCount <= 0 ) | 179 | if (maximalSize <= 0 || maximalCount <= 0) |
180 | { | 180 | { |
181 | Log.Info( "[ASSET CACHE]: Cenome asset cache is not enabled." ); | 181 | Log.Info("[ASSET CACHE]: Cenome asset cache is not enabled."); |
182 | m_enabled = false; | 182 | m_enabled = false; |
183 | return; | 183 | return; |
184 | } | 184 | } |
185 | 185 | ||
186 | if( expirationTime <= TimeSpan.Zero ) | 186 | if (expirationTime <= TimeSpan.Zero) |
187 | { | 187 | { |
188 | // Disable expiration time | 188 | // Disable expiration time |
189 | expirationTime = TimeSpan.MaxValue; | 189 | expirationTime = TimeSpan.MaxValue; |
@@ -191,14 +191,14 @@ namespace OpenSim.Region.CoreModules.Asset | |||
191 | 191 | ||
192 | // Create cache and add synchronization wrapper over it | 192 | // Create cache and add synchronization wrapper over it |
193 | m_cache = | 193 | m_cache = |
194 | CnmSynchronizedCache<string, AssetBase>.Synchronized( new CnmMemoryCache<string, AssetBase>( | 194 | CnmSynchronizedCache<string, AssetBase>.Synchronized(new CnmMemoryCache<string, AssetBase>( |
195 | maximalSize, maximalCount, expirationTime ) ); | 195 | maximalSize, maximalCount, expirationTime)); |
196 | m_enabled = true; | 196 | m_enabled = true; |
197 | Log.InfoFormat( | 197 | Log.InfoFormat( |
198 | "[ASSET CACHE]: Cenome asset cache enabled (MaxSize = {0} bytes, MaxCount = {1}, ExpirationTime = {2})", | 198 | "[ASSET CACHE]: Cenome asset cache enabled (MaxSize = {0} bytes, MaxCount = {1}, ExpirationTime = {2})", |
199 | maximalSize, | 199 | maximalSize, |
200 | maximalCount, | 200 | maximalCount, |
201 | expirationTime ); | 201 | expirationTime); |
202 | } | 202 | } |
203 | 203 | ||
204 | #region IImprovedAssetCache Members | 204 | #region IImprovedAssetCache Members |
@@ -209,10 +209,10 @@ namespace OpenSim.Region.CoreModules.Asset | |||
209 | /// <param name="asset"> | 209 | /// <param name="asset"> |
210 | /// The asset that is being cached. | 210 | /// The asset that is being cached. |
211 | /// </param> | 211 | /// </param> |
212 | public void Cache( AssetBase asset ) | 212 | public void Cache(AssetBase asset) |
213 | { | 213 | { |
214 | long size = asset.Data != null ? asset.Data.Length : 1; | 214 | long size = asset.Data != null ? asset.Data.Length : 1; |
215 | m_cache.Set( asset.ID, asset, size ); | 215 | m_cache.Set(asset.ID, asset, size); |
216 | m_cachedCount++; | 216 | m_cachedCount++; |
217 | } | 217 | } |
218 | 218 | ||
@@ -230,9 +230,9 @@ namespace OpenSim.Region.CoreModules.Asset | |||
230 | /// <param name="id"> | 230 | /// <param name="id"> |
231 | /// The expired asset's id. | 231 | /// The expired asset's id. |
232 | /// </param> | 232 | /// </param> |
233 | public void Expire( string id ) | 233 | public void Expire(string id) |
234 | { | 234 | { |
235 | m_cache.Remove( id ); | 235 | m_cache.Remove(id); |
236 | } | 236 | } |
237 | 237 | ||
238 | /// <summary> | 238 | /// <summary> |
@@ -250,14 +250,14 @@ namespace OpenSim.Region.CoreModules.Asset | |||
250 | /// Cache doesn't guarantee in any situation that asset is stored to it. | 250 | /// Cache doesn't guarantee in any situation that asset is stored to it. |
251 | /// </para> | 251 | /// </para> |
252 | /// </remarks> | 252 | /// </remarks> |
253 | public AssetBase Get( string id ) | 253 | public AssetBase Get(string id) |
254 | { | 254 | { |
255 | m_getCount++; | 255 | m_getCount++; |
256 | AssetBase assetBase; | 256 | AssetBase assetBase; |
257 | if( m_cache.TryGetValue( id, out assetBase ) ) | 257 | if (m_cache.TryGetValue(id, out assetBase)) |
258 | m_hitCount++; | 258 | m_hitCount++; |
259 | 259 | ||
260 | if( m_getCount == m_debugEpoch ) | 260 | if (m_getCount == m_debugEpoch) |
261 | { | 261 | { |
262 | Log.InfoFormat( | 262 | Log.InfoFormat( |
263 | "[ASSET CACHE]: Cached = {0}, Get = {1}, Hits = {2}%, Size = {3} bytes, Avg. A. Size = {4} bytes", | 263 | "[ASSET CACHE]: Cached = {0}, Get = {1}, Hits = {2}%, Size = {3} bytes, Avg. A. Size = {4} bytes", |
@@ -265,7 +265,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
265 | m_getCount, | 265 | m_getCount, |
266 | ((double) m_hitCount / m_getCount) * 100.0, | 266 | ((double) m_hitCount / m_getCount) * 100.0, |
267 | m_cache.Size, | 267 | m_cache.Size, |
268 | m_cache.Size / m_cache.Count ); | 268 | m_cache.Size / m_cache.Count); |
269 | m_getCount = 0; | 269 | m_getCount = 0; |
270 | m_hitCount = 0; | 270 | m_hitCount = 0; |
271 | m_cachedCount = 0; | 271 | m_cachedCount = 0; |
@@ -292,10 +292,10 @@ namespace OpenSim.Region.CoreModules.Asset | |||
292 | /// <param name="scene"> | 292 | /// <param name="scene"> |
293 | /// Region's scene. | 293 | /// Region's scene. |
294 | /// </param> | 294 | /// </param> |
295 | public void AddRegion( Scene scene ) | 295 | public void AddRegion(Scene scene) |
296 | { | 296 | { |
297 | if( m_enabled ) | 297 | if (m_enabled) |
298 | scene.RegisterModuleInterface<IImprovedAssetCache>( this ); | 298 | scene.RegisterModuleInterface<IImprovedAssetCache>(this); |
299 | } | 299 | } |
300 | 300 | ||
301 | /// <summary> | 301 | /// <summary> |
@@ -314,19 +314,19 @@ namespace OpenSim.Region.CoreModules.Asset | |||
314 | /// <param name="source"> | 314 | /// <param name="source"> |
315 | /// Configuration source. | 315 | /// Configuration source. |
316 | /// </param> | 316 | /// </param> |
317 | public void Initialise( IConfigSource source ) | 317 | public void Initialise(IConfigSource source) |
318 | { | 318 | { |
319 | m_cache = null; | 319 | m_cache = null; |
320 | m_enabled = false; | 320 | m_enabled = false; |
321 | 321 | ||
322 | IConfig moduleConfig = source.Configs[ "Modules" ]; | 322 | IConfig moduleConfig = source.Configs[ "Modules" ]; |
323 | if( moduleConfig == null ) | 323 | if (moduleConfig == null) |
324 | return; | 324 | return; |
325 | 325 | ||
326 | string name = moduleConfig.GetString( "AssetCaching" ); | 326 | string name = moduleConfig.GetString("AssetCaching"); |
327 | Log.DebugFormat( "[XXX] name = {0} (this module's name: {1}", name, Name ); | 327 | Log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name); |
328 | 328 | ||
329 | if( name != Name ) | 329 | if (name != Name) |
330 | return; | 330 | return; |
331 | 331 | ||
332 | // This module is used | 332 | // This module is used |
@@ -335,19 +335,19 @@ namespace OpenSim.Region.CoreModules.Asset | |||
335 | TimeSpan expirationTime = DefaultExpirationTime; | 335 | TimeSpan expirationTime = DefaultExpirationTime; |
336 | 336 | ||
337 | IConfig assetConfig = source.Configs[ "AssetCache" ]; | 337 | IConfig assetConfig = source.Configs[ "AssetCache" ]; |
338 | if( assetConfig != null ) | 338 | if (assetConfig != null) |
339 | { | 339 | { |
340 | // Get optional configurations | 340 | // Get optional configurations |
341 | maxSize = assetConfig.GetLong( "MaxSize", DefaultMaxSize ); | 341 | maxSize = assetConfig.GetLong("MaxSize", DefaultMaxSize); |
342 | maxCount = assetConfig.GetInt( "MaxCount", DefaultMaxCount ); | 342 | maxCount = assetConfig.GetInt("MaxCount", DefaultMaxCount); |
343 | expirationTime = | 343 | expirationTime = |
344 | TimeSpan.FromMinutes( assetConfig.GetInt( "ExpirationTime", (int) DefaultExpirationTime.TotalMinutes ) ); | 344 | TimeSpan.FromMinutes(assetConfig.GetInt("ExpirationTime", (int) DefaultExpirationTime.TotalMinutes)); |
345 | 345 | ||
346 | // Debugging purposes only | 346 | // Debugging purposes only |
347 | m_debugEpoch = assetConfig.GetInt( "DebugEpoch", 0 ); | 347 | m_debugEpoch = assetConfig.GetInt("DebugEpoch", 0); |
348 | } | 348 | } |
349 | 349 | ||
350 | Initialize( maxSize, maxCount, expirationTime ); | 350 | Initialize(maxSize, maxCount, expirationTime); |
351 | } | 351 | } |
352 | 352 | ||
353 | /// <summary> | 353 | /// <summary> |
@@ -381,7 +381,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
381 | /// The extra function stub is just that much cleaner. | 381 | /// The extra function stub is just that much cleaner. |
382 | /// </para> | 382 | /// </para> |
383 | /// </remarks> | 383 | /// </remarks> |
384 | public void RegionLoaded( Scene scene ) | 384 | public void RegionLoaded(Scene scene) |
385 | { | 385 | { |
386 | } | 386 | } |
387 | 387 | ||
@@ -391,7 +391,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
391 | /// <param name="scene"> | 391 | /// <param name="scene"> |
392 | /// Region scene that is being removed. | 392 | /// Region scene that is being removed. |
393 | /// </param> | 393 | /// </param> |
394 | public void RemoveRegion( Scene scene ) | 394 | public void RemoveRegion(Scene scene) |
395 | { | 395 | { |
396 | } | 396 | } |
397 | 397 | ||