예제 #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);
         }
     }
 }
예제 #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;
     }
 }
예제 #3
0
파일: AlbianChunk.cs 프로젝트: mbsky/albian
 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);
         }
     }
 }