[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
+2 -3
View File
@@ -6,11 +6,10 @@ import (
"net/netip"
"time"
"github.com/eko/gocache/v3/cache"
nbdns "github.com/netbirdio/netbird/dns"
"github.com/netbirdio/netbird/management/domain"
"github.com/netbirdio/netbird/management/server/activity"
nbcache "github.com/netbirdio/netbird/management/server/cache"
nbcontext "github.com/netbirdio/netbird/management/server/context"
"github.com/netbirdio/netbird/management/server/idp"
nbpeer "github.com/netbirdio/netbird/management/server/peer"
@@ -20,7 +19,7 @@ import (
"github.com/netbirdio/netbird/route"
)
type ExternalCacheManager cache.CacheInterface[*idp.UserData]
type ExternalCacheManager nbcache.UserDataCache
type Manager interface {
GetOrCreateAccountByUser(ctx context.Context, userId, domain string) (*types.Account, error)