MSP-2370 use more abstract naming in cache repo

This commit is contained in:
d1slike committed 2023-11-14 12:35:24 +03:00
1 parent 7069f43366
commit 365bddceda
1 file changed
+6 -6
+6 -6
View File
@@ -20,18 +20,18 @@ func NewAuthorizationCache(duration time.Duration) *AuthorizationCache {
}
}
func (r AuthorizationCache) Get(ctx context.Context, applicationId int, endpoint string) (bool, error) {
key := r.key(applicationId, endpoint)
func (r AuthorizationCache) Get(ctx context.Context, id int, endpoint string) (bool, error) {
key := r.key(id, endpoint)
_, ok := r.cache.Get(key)
return ok, nil
}
func (r AuthorizationCache) SetAuthorized(ctx context.Context, applicationId int, endpoint string) error {
key := r.key(applicationId, endpoint)
func (r AuthorizationCache) SetAuthorized(ctx context.Context, id int, endpoint string) error {
key := r.key(id, endpoint)
r.cache.Set(key, nil, r.duration)
return nil
}
func (r AuthorizationCache) key(applicationId int, endpoint string) string {
return fmt.Sprintf("%d:%s", applicationId, endpoint)
func (r AuthorizationCache) key(id int, endpoint string) string {
return fmt.Sprintf("%d:%s", id, endpoint)
}