public Task SetAsync(GpuName gpuName) { if (gpuName == null || !gpuName.IsValid()) { return(TaskEx.CompletedTask); } var db = _connection.GetDatabase(); return(db.HashSetAsync(_redisKeyGpuName, gpuName.ToString(), VirtualRoot.JsonSerializer.Serialize(gpuName))); }
public Task DeleteAsync(GpuName gpuName) { if (gpuName == null || !gpuName.IsValid()) { return(TaskEx.CompletedTask); } var db = _connection.GetDatabase(); return(db.HashDeleteAsync(_redisKeyGpuName, gpuName.ToString())); }
public void Remove(GpuName gpuName) { if (!IsReadied) { return; } if (gpuName == null || !gpuName.IsValid()) { return; } _gpuNameSet.Remove(gpuName); _gpuNameRedis.DeleteAsync(gpuName); }
public void Set(GpuName gpuName) { if (!IsReadied) { return; } if (gpuName == null || !gpuName.IsValid()) { return; } _gpuNameSet.Add(gpuName); _gpuNameRedis.SetAsync(gpuName); }
public Task <List <GpuName> > GetAllAsync() { var db = _connection.GetDatabase(); return(db.HashGetAllAsync(_redisKeyGpuName).ContinueWith(t => { List <GpuName> list = new List <GpuName>(); foreach (var item in t.Result) { if (item.Value.HasValue) { GpuName data = VirtualRoot.JsonSerializer.Deserialize <GpuName>(item.Value); if (data != null) { list.Add(data); } } } return list; })); }
public void GpuNameTest() { HashSet <GpuName> hashSet = new HashSet <GpuName>(); GpuName gpuName1 = new GpuName { Name = "580 Series", TotalMemory = NTKeyword.ULongG * 8 }; hashSet.Add(gpuName1); Console.WriteLine(gpuName1.ToString()); GpuName gpuName2 = new GpuName { Name = "580 Series", TotalMemory = (ulong)(NTKeyword.ULongG * 7.9) }; hashSet.Add(gpuName2); Console.WriteLine(gpuName2.ToString()); Assert.AreEqual(gpuName1.GetHashCode(), gpuName2.GetHashCode()); Assert.AreEqual(1, hashSet.Count); }
public void AddCount(GpuType gpuType, string gpuName, ulong gpuTotalMemory) { if (gpuType == GpuType.Empty || string.IsNullOrEmpty(gpuName) || !GpuName.IsValidTotalMemory(gpuTotalMemory)) { return; } GpuName key = new GpuName { TotalMemory = gpuTotalMemory, Name = gpuName, GpuType = gpuType }; if (_gpuNameCountDic.TryGetValue(key, out int count)) { _gpuNameCountDic[key] = count + 1; } else { _gpuNameCountDic.Add(key, 1); } }
bool IGpuName.IsValid() { return(GpuName.IsValid(this.GpuType, this.Name, this.TotalMemory)); }
public void RemoveGpuNameAsync(GpuName gpuName, Action <ResponseBase, Exception> callback) { JsonRpcRoot.SignPostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IGpuNameController.RemoveGpuName), new DataRequest <GpuName> { Data = gpuName }, callback, timeountMilliseconds: 5 * 1000); }