From 5b0909e585843cde2b83171fc5d60dbc14106efb Mon Sep 17 00:00:00 2001 From: michaeljguarino Date: Sat, 7 Jan 2023 13:22:16 -0500 Subject: [PATCH] Fix cache setup --- apps/core/lib/core/clients/hydra.ex | 1 - apps/core/lib/core/guardian.ex | 2 +- config/config.exs | 14 ++++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/core/lib/core/clients/hydra.ex b/apps/core/lib/core/clients/hydra.ex index 391ef7f87..525ee35a8 100644 --- a/apps/core/lib/core/clients/hydra.ex +++ b/apps/core/lib/core/clients/hydra.ex @@ -43,7 +43,6 @@ defmodule Core.Clients.Hydra do ] end - @duration 60 * 60 * 24 def get_configuration() do public_url("/.well-known/openid-configuration") diff --git a/apps/core/lib/core/guardian.ex b/apps/core/lib/core/guardian.ex index afaf44a2b..b92c572c4 100644 --- a/apps/core/lib/core/guardian.ex +++ b/apps/core/lib/core/guardian.ex @@ -19,7 +19,7 @@ defmodule Core.Guardian do end def resource_from_claims(_claims), do: {:error, :not_authorized} - @decorate cacheable(cache: Core.Cache, key: {:login_v2, id}, opts: [ttl: @ttl], match: &allow/1) + @decorate cacheable(cache: Core.Cache, key: {:login, id}, opts: [ttl: @ttl], match: &allow/1) def fetch_user(id) do Users.get_user(id) |> Core.Services.Rbac.preload() diff --git a/config/config.exs b/config/config.exs index 7e72c2b42..4c1afcb76 100644 --- a/config/config.exs +++ b/config/config.exs @@ -74,7 +74,7 @@ config :core, Core.Email.Mailer, config :core, Core.PartitionedCache, primary: [ - gc_interval: :timer.seconds(3600), + gc_interval: :timer.hours(1), backend: :shards, partitions: 2, allocated_memory: 1000 * 1000 * 500 @@ -82,7 +82,17 @@ config :core, Core.PartitionedCache, config :core, Core.Cache, local: Core.Cache.Local, - node_selector: Nebulex.Adapters.Dist + node_selector: Nebulex.Adapters.Dist, + primary: [ + gc_interval: :timer.hours(1), + backend: :shards, + partitions: 2, + allocated_memory: 1000 * 1000 * 500 + ], + gc_interval: :timer.hours(1), + backend: :shards, + partitions: 2, + allocated_memory: 1000 * 1000 * 500 config :core, Core.Conduit.Broker, adapter: ConduitAMQP,