reduce caching
This commit is contained in:
parent
d75a8e75c6
commit
d88adf4293
2 changed files with 8 additions and 5 deletions
|
|
@ -7,10 +7,10 @@ defmodule Aprsme.CachedQueries do
|
||||||
alias Aprsme.Packets
|
alias Aprsme.Packets
|
||||||
alias Aprsme.Repo
|
alias Aprsme.Repo
|
||||||
|
|
||||||
# 2 minutes for frequently changing data
|
# 1 minute for frequently changing data
|
||||||
@cache_ttl_short to_timeout(minute: 2)
|
@cache_ttl_short to_timeout(minute: 1)
|
||||||
# 15 minutes for moderately changing data
|
# 1 minute for moderately changing data
|
||||||
@cache_ttl_medium to_timeout(minute: 15)
|
@cache_ttl_medium to_timeout(minute: 1)
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Get recent packets with caching
|
Get recent packets with caching
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,10 @@ defmodule AprsmeWeb.Plugs.IPGeolocation do
|
||||||
ip_from_remote =
|
ip_from_remote =
|
||||||
case conn.remote_ip do
|
case conn.remote_ip do
|
||||||
{a, b, c, d} -> "#{a}.#{b}.#{c}.#{d}"
|
{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
|
_ -> nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue