public async Task <URL> GetByIdAsync(ShortURL id) { string key = id.ToString(); string value = await _redisDB.StringGetAsync(key); return(new URL(value, id)); }
public async Task <string> CreateURLAsync(string extendedURL) { Guard.Against.NullOrEmpty(extendedURL, "URL value"); Guard.Against.OutOfRange(extendedURL.Length, "URL value", 1, _config.MaxURLChars); string res = null; try { ShortURL surl = ShortURL.ComputeShortURLFromExtendedURL(extendedURL); if (!await _urlRepository.ExistsAsync(surl)) { URL newURL = new URL(extendedURL, surl); await _urlRepository.AddAsync(newURL); } res = RemoveBase64Strings(surl.ToString()); } catch (Exception excp) { _logger.LogError(excp, $"Error creating url with value: {extendedURL}."); } return(res); }
public async Task <bool> ExistsAsync(ShortURL id) { return(await _redisDB.KeyExistsAsync(id.ToString())); }
public void DeleteFireAndForget(ShortURL entity) { _redisDB.KeyDelete(entity.ToString(), flags: CommandFlags.FireAndForget); }