fix(fuel-web-utils): load key from db and store for 10 minutes #470
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
load_from_db
method inApiKeysManager
and eliminated the preloading of API keys from the database during initialization inServerState
for bothservices/api
andservices/webserver
. This simplifies the initialization process and avoids redundant caching logic. [1] [2] [3]Enhancements to in-memory API key storage:
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:
storage_key
method inApiKey
to directly use thekey
field instead of concatenating theid
anduser
fields.Code cleanup:
KeyStorage
trait import inservices/api/src/server/state.rs
andservices/webserver/src/server/state.rs
to clean up imports. [1] [2]