From d88adf429303a9eab2005ebaffc20417b5cf4da4 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 11 Jul 2025 14:42:01 -0500 Subject: [PATCH] reduce caching --- lib/aprsme/cached_queries.ex | 8 ++++---- lib/aprsme_web/plugs/ip_geolocation.ex | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/aprsme/cached_queries.ex b/lib/aprsme/cached_queries.ex index e4c3d7a..416a7b1 100644 --- a/lib/aprsme/cached_queries.ex +++ b/lib/aprsme/cached_queries.ex @@ -7,10 +7,10 @@ defmodule Aprsme.CachedQueries do alias Aprsme.Packets alias Aprsme.Repo - # 2 minutes for frequently changing data - @cache_ttl_short to_timeout(minute: 2) - # 15 minutes for moderately changing data - @cache_ttl_medium to_timeout(minute: 15) + # 1 minute for frequently changing data + @cache_ttl_short to_timeout(minute: 1) + # 1 minute for moderately changing data + @cache_ttl_medium to_timeout(minute: 1) @doc """ Get recent packets with caching diff --git a/lib/aprsme_web/plugs/ip_geolocation.ex b/lib/aprsme_web/plugs/ip_geolocation.ex index 9c69999..05bb036 100644 --- a/lib/aprsme_web/plugs/ip_geolocation.ex +++ b/lib/aprsme_web/plugs/ip_geolocation.ex @@ -89,7 +89,10 @@ defmodule AprsmeWeb.Plugs.IPGeolocation do ip_from_remote = case conn.remote_ip do {a, b, c, d} -> "#{a}.#{b}.#{c}.#{d}" - {a, b, c, d, e, f, g, h} -> "#{a}:#{b}:#{c}:#{d}:#{e}:#{f}:#{g}:#{h}" + {a, b, c, d, e, f, g, h} -> + # Convert IPv6 tuple to proper IPv6 format + :inet.ntoa({a, b, c, d, e, f, g, h}) + |> to_string() _ -> nil end