[management] Add redis cache (#3516)

Refactor IdP user data caching by introducing a Redis cache implementation alongside an in-memory fallback, adding a Marshaler interface for flexible serialization, and updating related tests and account management code.

- Added a new cache store implementation with support for Redis and in-memory backends.
- Introduced Marshaler and wrapper types for handling serialization with msgpack and JSON.
- Updated account and user management modules to integrate and test the new caching strategy.
This commit is contained in:
Maycon Santos
2025-03-18 11:07:20 +01:00
committed by GitHub
parent 0fa65eab5d
commit 1d9fced073
11 changed files with 544 additions and 160 deletions
+18
View File
@@ -2,6 +2,7 @@ package idp
import (
"context"
"encoding/json"
"fmt"
"net/http"
"strings"
@@ -73,6 +74,23 @@ type UserData struct {
AppMetadata AppMetadata `json:"app_metadata"`
}
func (u *UserData) MarshalBinary() (data []byte, err error) {
return json.Marshal(u)
}
func (u *UserData) UnmarshalBinary(data []byte) (err error) {
return json.Unmarshal(data, &u)
}
func (u *UserData) Marshal() (data string, err error) {
d, err := json.Marshal(u)
return string(d), err
}
func (u *UserData) Unmarshal(data []byte) (err error) {
return json.Unmarshal(data, &u)
}
// AppMetadata user app metadata to associate with a profile
type AppMetadata struct {
// WTAccountID is a NetBird (previously Wiretrustee) account id to update in the IDP