コード例 #1
0
 /// <summary>
 /// Check whether we can send a CachedObjectUpdate to the client
 /// </summary>
 /// <param name="AgentID"></param>
 /// <param name="localID"></param>
 /// <param name="CurrentEntityCRC"></param>
 /// <returns></returns>
 public bool UseCachedObject(UUID AgentID, uint localID, uint CurrentEntityCRC)
 {
     lock (ObjectCacheAgents)
     {
         Dictionary <uint, uint> InternalCache;
         if (ObjectCacheAgents.TryGetValue(AgentID, out InternalCache))
         {
             uint CurrentCachedCRC = 0;
             if (InternalCache.TryGetValue(localID, out CurrentCachedCRC))
             {
                 if (CurrentEntityCRC == CurrentCachedCRC)
                 {
                     //The client knows of the newest version
                     return(true);
                 }
                 //else, update below
             }
         }
         else
         {
             InternalCache = new Dictionary <uint, uint>();
         }
         InternalCache[localID]     = CurrentEntityCRC;
         ObjectCacheAgents[AgentID] = InternalCache;
         return(false);
     }
 }
コード例 #2
0
        /// <summary>
        ///     Gets an item from the cache
        /// </summary>
        /// <typeparam name="TValueType">Item type</typeparam>
        /// <param name="key">Key to search for</param>
        /// <returns>The item associated with the key</returns>
        public virtual TValueType Get <TValueType>(TKeyType key)
        {
            object tempItem;

            return(InternalCache.TryGetValue(key, out tempItem)
                       ? tempItem.TryTo(default(TValueType))
                       : default(TValueType));
        }
コード例 #3
0
        /// <summary>
        /// Gets an item from the cache
        /// </summary>
        /// <typeparam name="ValueType">Item type</typeparam>
        /// <param name="Key">Key to search for</param>
        /// <returns>The item associated with the key</returns>
        public virtual ValueType Get <ValueType>(KeyType Key)
        {
            object TempItem = null;

            return(InternalCache.TryGetValue(Key, out TempItem) ? TempItem.To(default(ValueType)) : default(ValueType));
        }