Exemple #1
0
 public void Set(string key, object value)
 {
     if (ValidateService.IsNullOrEmpty(key))
     {
         throw new ArgumentNullException("key", string.Format("key is null or empty in the {0} chunk.", _name));
     }
     lock (_locker)
     {
         if (_ht.ContainsKey(key))
         {
             IAlbianChunkObject obj = new AlbianChunkObject
             {
                 Key        = key,
                 Value      = value,
                 CreateTime = DateTime.Now
             };
             _ht[key] = obj;
         }
         else
         {
             IAlbianChunkObject obj = new AlbianChunkObject
             {
                 Key        = key,
                 Value      = value,
                 CreateTime = DateTime.Now
             };
             _ht.Add(key, obj);
         }
     }
 }
Exemple #2
0
 public void Update(string key, object value)
 {
     if (ValidateService.IsNullOrEmpty(key))
     {
         throw new ArgumentNullException("key", string.Format("key is null or empty in the {0} chunk.", _name));
     }
     lock (_locker)
     {
         if (!_ht.ContainsKey(key))
         {
             throw new AlbianChunkException(string.Format("the {0} cached is not exist in the {1} chunk.", key,
                                                          _name));
         }
         IAlbianChunkObject obj = new AlbianChunkObject
         {
             Key        = key,
             Value      = value,
             CreateTime = DateTime.Now
         };
         _ht[key] = obj;
     }
 }
Exemple #3
0
 public void Insert(string key, object value)
 {
     if (ValidateService.IsNullOrEmpty(key))
     {
         throw new ArgumentNullException("key", string.Format("key is null or empty in the {0} chunk.", _name));
     }
     lock (_locker)
     {
         if (_ht.ContainsKey(key))
         {
             throw new AlbianChunkException(string.Format("the {0} cached is exist in the {1} chunk.", key,
                                                         _name));
         }
         else
         {
             IAlbianChunkObject obj = new AlbianChunkObject
                                    {
                                        Key = key,
                                        Value = value,
                                        CreateTime = DateTime.Now
                                    };
             _ht.Add(key, obj);
         }
     }
 }