Skip to content

auth: db transaction drain into cached map lookups#3

Open
EisigesEis wants to merge 3 commits into
SyST3MDeV:mainfrom
EisigesEis:feature-auth
Open

auth: db transaction drain into cached map lookups#3
EisigesEis wants to merge 3 commits into
SyST3MDeV:mainfrom
EisigesEis:feature-auth

Conversation

@EisigesEis

@EisigesEis EisigesEis commented Jul 2, 2026

Copy link
Copy Markdown
Contributor
  • Replace: load all api keys from db > hash > constant time check all keys on each request
  • Rename: auth.ts > authuser.ts, apikeys.ts > authgameserver.ts
    • Initial key drain wrapped in db transaction
  • Add: apikeycache.ts
    • Cache.refresh() Initial drain loads all hashed keys into memory buffer
    • Cache.get(key) .has(key): On each user request: hash > Map lookup

- Replace: load all api keys from db > hash > constant time check all keys on each request
- Rename: auth.ts > authuser.ts, apikeys.ts > authgameserver.ts
  - Initial key drain wrapped in db transaction
- Add: apikeycache.ts
  - Cache.refresh() Initial drain loads all hashed keys into memory buffer
  - Cache.get(key) .has(key): On each user request: hash > Map lookup
@EisigesEis

EisigesEis commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Fine to sit there for a while or just act as inspiration :)

Should be more performance on each server response. Downsides:

  • We lost timing safe compare (could restore that tho)
  • We keep the map in cache at all times. Will not be ideal for high player count. Maybe need something with heartbeats and live/cold storage later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant