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); } } }
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; } }
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); } } }