aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authordiva2009-05-26 21:24:18 +0000
committerdiva2009-05-26 21:24:18 +0000
commitce5225e6dc7a8a86a13a274f6107be4fb5facbea (patch)
treeb414690f73b442cf908003efd364a300196f24f9 /OpenSim
parentChanged the order of things in Scene creation. This piece of code is very jib... (diff)
downloadopensim-SC_OLD-ce5225e6dc7a8a86a13a274f6107be4fb5facbea.zip
opensim-SC_OLD-ce5225e6dc7a8a86a13a274f6107be4fb5facbea.tar.gz
opensim-SC_OLD-ce5225e6dc7a8a86a13a274f6107be4fb5facbea.tar.bz2
opensim-SC_OLD-ce5225e6dc7a8a86a13a274f6107be4fb5facbea.tar.xz
Experimental alternative cache module implementation, using GlynnTucker.Cache.dll.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs126
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml1
2 files changed, 127 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
new file mode 100644
index 0000000..f0a43b0
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
@@ -0,0 +1,126 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using log4net;
29using System;
30using System.IO;
31using System.Collections.Generic;
32using System.Reflection;
33using GlynnTucker.Cache;
34using Nini.Config;
35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Services.Interfaces;
39
40namespace OpenSim.Region.CoreModules.Asset
41{
42 public class GlynnTuckerAssetCache : ISharedRegionModule, IImprovedAssetCache
43 {
44 private static readonly ILog m_log =
45 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType);
47
48 private bool m_Enabled = false;
49 private ICache m_Cache = new GlynnTucker.Cache.SimpleMemoryCache();
50
51 public string Name
52 {
53 get { return "GlynnTuckerAssetCache"; }
54 }
55
56 public void Initialise(IConfigSource source)
57 {
58 IConfig moduleConfig = source.Configs["Modules"];
59
60 if (moduleConfig != null)
61 {
62 string name = moduleConfig.GetString("AssetCaching", "GlynnTuckerAssetCache");
63 m_log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name);
64
65 if (name == Name)
66 {
67 m_Enabled = true;
68
69 m_log.Info("[ASSET CACHE]: GlynnTucker asset cache enabled");
70
71 }
72 }
73 }
74
75 public void PostInitialise()
76 {
77 }
78
79 public void Close()
80 {
81 }
82
83 public void AddRegion(Scene scene)
84 {
85 if (m_Enabled)
86 scene.RegisterModuleInterface<IImprovedAssetCache>(this);
87 }
88
89 public void RemoveRegion(Scene scene)
90 {
91 }
92
93 public void RegionLoaded(Scene scene)
94 {
95 }
96
97 ////////////////////////////////////////////////////////////
98 // IImprovedAssetCache
99 //
100
101 public void Cache(AssetBase asset)
102 {
103 if (asset != null)
104 m_Cache.AddOrUpdate(asset.ID, asset);
105 }
106
107 public AssetBase Get(string id)
108 {
109 Object asset = null;
110 m_Cache.TryGet(id, out asset);
111 return (AssetBase)asset;
112 }
113
114 public void Expire(string id)
115 {
116 Object asset = null;
117 if (m_Cache.TryGet(id, out asset))
118 m_Cache.Remove(id);
119 }
120
121 public void Clear()
122 {
123 m_Cache.Clear();
124 }
125 }
126}
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index bc0f4b5..393f340 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -18,6 +18,7 @@
18 <RegionModule id="RemoteAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectors.Asset.RemoteAssetServicesConnector" /> 18 <RegionModule id="RemoteAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectors.Asset.RemoteAssetServicesConnector" />
19 <RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectors.Asset.HGAssetBroker" /> 19 <RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectors.Asset.HGAssetBroker" />
20 <RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" /> 20 <RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" />
21 <RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" />
21 <RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" /> 22 <RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" />
22 <RegionModule id="Chat" type="OpenSim.Region.CoreModules.Avatar.Chat.ChatModule" /> 23 <RegionModule id="Chat" type="OpenSim.Region.CoreModules.Avatar.Chat.ChatModule" />
23 </Extension> 24 </Extension>