Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [Unreleased]

### Added

- [TD-7175] Added search domain in cache by name

## [7.7.0] 2025-06-20

### Added
Expand Down
16 changes: 16 additions & 0 deletions lib/td_cache/domain_cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,22 @@ defmodule TdCache.DomainCache do
end
end

def get_by_name(name) when is_binary(name) do
case Redix.command(["HGETALL", @ids_to_names_key]) do
{:ok, data} ->
data
|> Enum.chunk_every(2)
|> Enum.find(fn [_id, stored_name] -> stored_name == name end)
|> case do
[id, _] -> {:ok, read_domain(id)}
_ -> {:error, :not_found}
end

_ ->
{:error, :redis_failure}
end
end

defp get_deleted_domains do
case Redix.command(["SMEMBERS", @deleted_ids]) do
{:ok, ids} -> Enum.map(ids, &String.to_integer/1)
Expand Down
Loading