xgeek116

xgeek116

Hello,

I have created an Elixir library that checks the validity of a JWT token, but to do that the lib will fetch the public key from a remote server (the url of the remote server is stored as an env variable in the consumer application - config.exs because we can’t store vars in the lib).

My question is : how can I improve the process by storing the public key somewhere (avoid storing them in consumer applications ?), instead of fetching the key for every request.

Thanks

Showing Posts 1 to 1

Qqwy

Qqwy

TypeCheck Core Team

It depends a little bit on your use case.

If there is only a single public key you might need, i.e. it is a global value for the whole application, then you could use Application.put_env/Application.get_env.

If however you want to handle multiple values, like one per user in an application that might serve multiple users at the same time, then you probably want to use a caching library instead.
There are some great caching libraries which you could use on HexPM, the most well-known one probably being cachex, though there are many.

If you want to build something yourself, you might start with an Agent to store some common state in. (If speed ever becomes a problem, you could move on to :ets instead). But a caching library probably suffices.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
leoschweizer
Hi, we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
csmr
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley: Mutonex gamedesign was finish...
New
perzanko
Do we have maintainer of absinthe-graphql/dataloader here? We have a PR that we’d like to merge to the library. Relatively small additive...
New

Other Trending Topics Top

rodloboz
Hi everyone! I’d like to share Fude (筆, “brush”), a charting library for Phoenix LiveView. I built it for dashboards and reports where y...
New
dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews