public override void SetValueHandler(ElementRequestReader request) { long md5 = MD5Utility.GetMD5(request.element.key); if (Global.LocalStorage.Contains(md5)) { //the bucket already exsit using (var bucket = Global.LocalStorage.UseBucket(md5)) { //different keys may end up in the same bucket(Hash Collision) bucket.elements.ForEach(element_accessor => { if (element_accessor.key == request.element.key) { //if already in the bucket, update the value element_accessor.value = request.element.value; return; } }); //upon here,no entry for this key exist bucket.elements.Add(request.element); } } else { //no bucket is ever exist, creat for my own! Bucket newbucket = new Bucket(); Global.LocalStorage.SaveBucket(md5, newbucket); using (var bucket = Global.LocalStorage.UseBucket(md5)) { bucket.elements.Add(request.element); } } }