Browse Source

feat: use proper session cache :)))

tags/v0.33.0
Inhji Y. 2 months ago
parent
commit
48a7331fcf
6 changed files with 25 additions and 3 deletions
  1. +1
    -0
      .env.example
  2. +4
    -0
      .gitignore
  3. +3
    -1
      apps/tomie_web/lib/tomie_web/application.ex
  4. +2
    -1
      apps/tomie_web/lib/tomie_web/endpoint.ex
  5. +4
    -1
      config/config.exs
  6. +11
    -0
      config/releases.exs

+ 1
- 0
.env.example View File

@@ -4,3 +4,4 @@ HOST=
PORT=
SECRET_KEY_BASE=
UPLOAD_DIR=
CACHE_DIR=

+ 4
- 0
.gitignore View File

@@ -22,4 +22,8 @@ erl_crash.dump
# Ignore environment file
.env

# Ignore Uploads dir
/uploads/

# Ignore Cache dir
/cache/

+ 3
- 1
apps/tomie_web/lib/tomie_web/application.ex View File

@@ -11,7 +11,9 @@ defmodule TomieWeb.Application do
# Start the endpoint when the application starts
TomieWeb.Endpoint,
# Starts a worker by calling: TomieWeb.Worker.start_link(arg)
{Phoenix.PubSub, name: TomieWeb.PubSub}
{Phoenix.PubSub, name: TomieWeb.PubSub},
# Starts Mnesia Store for Pow
Pow.Store.Backend.MnesiaCache
]

# See https://hexdocs.pm/elixir/Supervisor.html


+ 2
- 1
apps/tomie_web/lib/tomie_web/endpoint.ex View File

@@ -7,7 +7,8 @@ defmodule TomieWeb.Endpoint do
@session_options [
store: :cookie,
key: "_tomie_web_key",
signing_salt: "bnetjq+s"
signing_salt: "bnetjq+s",
max_age: 1_209_600
]

socket "/live", Phoenix.LiveView.Socket,


+ 4
- 1
config/config.exs View File

@@ -44,7 +44,10 @@ config :tomie_web, TomieWeb.Endpoint,
config :tomie_web, :pow,
user: Users.User,
repo: Db.Repo,
web_module: TomieWeb
web_module: TomieWeb,
cache_store_backend: Pow.Store.Backend.MnesiaCache

config :mnesia, dir: 'cache'

# Configures Elixir's Logger
config :logger, :console,


+ 11
- 0
config/releases.exs View File

@@ -41,6 +41,17 @@ upload_dir =
config :waffle,
storage_dir_prefix: upload_dir

mnesia_dir =
System.get_env("CACHE_DIR") ||
raise """
environment variable CACHE_DIR is missing.
for example: /opt/tomie/cache
"""

config :tomie_web, :pow, cache_store_backend: Pow.Store.Backend.MnesiaCache

config :mnesia, dir: mnesia_dir

# ## Using releases (Elixir v1.9+)
#
# If you are doing OTP releases, you need to instruct Phoenix


Loading…
Cancel
Save