Skip to content

Conversation

luizstacio
Copy link
Member

This pull request refactors the API key management system by removing database preloading for API keys, introducing expiration logic for in-memory storage, and simplifying related code. The changes aim to improve performance and reduce unnecessary database operations while maintaining functionality.

Refactoring API key management:

  • Removed the load_from_db method in ApiKeysManager and eliminated the preloading of API keys from the database during initialization in ServerState for both services/api and services/webserver. This simplifies the initialization process and avoids redundant caching logic. [1] [2] [3]

Enhancements to in-memory API key storage:

  • Updated InMemoryApiKeyStorage to store API keys with a timestamp (DashMap<String, (ApiKey, Instant)>) and introduced expiration logic. Keys older than 10 minutes are considered expired and removed during retrieval or lookup. [1] [2] [3] [4]

Simplification of storage key generation:

  • Simplified the storage_key method in ApiKey to directly use the key field instead of concatenating the id and user fields.

Code cleanup:

  • Removed unused KeyStorage trait import in services/api/src/server/state.rs and services/webserver/src/server/state.rs to clean up imports. [1] [2]

rodrigobranas
rodrigobranas previously approved these changes May 22, 2025
@luizstacio luizstacio changed the title fix: load key from db and store for 10 minutes fix(fuel-web-utils): load key from db and store for 10 minutes May 22, 2025
@luizstacio luizstacio closed this May 22, 2025
@luizstacio luizstacio deleted the ls/fix/cache-retrive branch May 23, 2025 02:46
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.

2 participants