mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-13 00:49:07 +02:00
[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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user