public IList <UserDataModel> GetFakeUsers(IDbConnection connection, int count = -1) { var fakeNames = _userNameSercherPkCache.TryFind(connection, FakeUserPrefix, _userCache); var fnCount = fakeNames.Count; if (count == -1) { count = fnCount; } if (count > fnCount) { count = fnCount; } var ids = fakeNames.Select(i => i.Value).OrderBy(i => i).Take(count).ToList(); return(_userCache.GetDataModelItems(connection, ids)); }
public IList <NameIdInt> FilterUserName(IDbConnection connection, string partUserName) { var locals = _userNameSercherPkCache.TryFind(connection, partUserName, _userCache); if (locals.Count > 0) { return(locals.Select(i => new NameIdInt(i.Value, i.Key)).ToList()); } var names = _userRepo.FilterUserName(connection, partUserName); if (names.Count <= 0) { return(new List <NameIdInt>()); } foreach (var un in names) { _userNameSercherPkCache.AddOrUpdate(connection, un.Name, un.Id, _userCache); } return(names); }