diff options
author | Melanie | 2012-03-09 22:59:23 +0000 |
---|---|---|
committer | Melanie | 2012-03-09 22:59:23 +0000 |
commit | 5c5a49379118330627af0b5648e6ce83a3b209ea (patch) | |
tree | 2791f811ea42039e59098490cf0835add25c319f /OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs | |
parent | fix for NPC not playing internal animations (diff) | |
parent | More on inventory transfer hold ups: (diff) | |
download | opensim-SC_OLD-5c5a49379118330627af0b5648e6ce83a3b209ea.zip opensim-SC_OLD-5c5a49379118330627af0b5648e6ce83a3b209ea.tar.gz opensim-SC_OLD-5c5a49379118330627af0b5648e6ce83a3b209ea.tar.bz2 opensim-SC_OLD-5c5a49379118330627af0b5648e6ce83a3b209ea.tar.xz |
Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs new file mode 100644 index 0000000..0fe778d --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs | |||
@@ -0,0 +1,59 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | |||
4 | using OpenSim.Framework; | ||
5 | using OpenMetaverse; | ||
6 | |||
7 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | ||
8 | { | ||
9 | public class InventoryCache | ||
10 | { | ||
11 | private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour | ||
12 | |||
13 | private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>(); | ||
14 | private static ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>>(); | ||
15 | |||
16 | public void Cache(UUID userID, InventoryFolderBase root) | ||
17 | { | ||
18 | lock (m_RootFolders) | ||
19 | m_RootFolders.AddOrUpdate(userID, root, CACHE_EXPIRATION_SECONDS); | ||
20 | } | ||
21 | |||
22 | public InventoryFolderBase GetRootFolder(UUID userID) | ||
23 | { | ||
24 | InventoryFolderBase root = null; | ||
25 | if (m_RootFolders.TryGetValue(userID, out root)) | ||
26 | return root; | ||
27 | |||
28 | return null; | ||
29 | } | ||
30 | |||
31 | public void Cache(UUID userID, AssetType type, InventoryFolderBase folder) | ||
32 | { | ||
33 | lock (m_FolderTypes) | ||
34 | { | ||
35 | Dictionary<AssetType, InventoryFolderBase> ff = null; | ||
36 | if (!m_FolderTypes.TryGetValue(userID, out ff)) | ||
37 | { | ||
38 | ff = new Dictionary<AssetType, InventoryFolderBase>(); | ||
39 | m_FolderTypes.Add(userID, ff, CACHE_EXPIRATION_SECONDS); | ||
40 | } | ||
41 | if (!ff.ContainsKey(type)) | ||
42 | ff.Add(type, folder); | ||
43 | } | ||
44 | } | ||
45 | |||
46 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) | ||
47 | { | ||
48 | Dictionary<AssetType, InventoryFolderBase> ff = null; | ||
49 | if (m_FolderTypes.TryGetValue(userID, out ff)) | ||
50 | { | ||
51 | InventoryFolderBase f = null; | ||
52 | if (ff.TryGetValue(type, out f)) | ||
53 | return f; | ||
54 | } | ||
55 | |||
56 | return null; | ||
57 | } | ||
58 | } | ||
59 | } | ||