public async Task AddAsync(IAutoCompleteModel item) { if (item.AutoCompleteItem != null && !string.IsNullOrEmpty(item.AutoCompleteItem.Key)) { await InsertValue(item.AutoCompleteItem.SetName, item.AutoCompleteItem.Key, item.AutoCompleteItem); } }
public async Task RemoveAsync(IAutoCompleteModel item) { if (!_redisConfigurationOptions.Value.EnableAutoComplete) { return; } await _redisAutoComplete.RemoveAsync(item); }
public async Task RemoveAsync(IAutoCompleteModel item) { if (item == null || string.IsNullOrEmpty(item.AutoCompleteItem.Key)) { return; } var key = item.AutoCompleteItem.Key.ToLower(); var existingItems = await this.GetAsync(item.AutoCompleteItem.SetName, key.Substring(0, item.AutoCompleteItem.Key.Length - 1)); if (existingItems != null && existingItems.Count > 0) { var deleteItemKey = string.Format("{0}*#*{1}*#*", item.AutoCompleteItem.Key.ToLower(), JsonConvert.SerializeObject(item.AutoCompleteItem)); await _redisConnectionFactory.Client.Database.SortedSetRemoveAsync(item.AutoCompleteItem.SetName, deleteItemKey); } }