Commit d76069cd authored by Harrison Healey's avatar Harrison Healey

Revert accidental changes to caching layer

parent eff68da2
......@@ -18,11 +18,10 @@ func (s *LocalCacheSupplier) handleClusterInvalidateRole(msg *model.ClusterMessa
}
func (s *LocalCacheSupplier) RoleSave(ctx context.Context, role *model.Role, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
result := s.Next().RoleSave(ctx, role, hints...)
if len(role.Id) != 0 {
s.doInvalidateCacheCluster(s.roleCache, role.Name)
defer s.doInvalidateCacheCluster(s.roleCache, role.Name)
}
return result
return s.Next().RoleSave(ctx, role, hints...)
}
func (s *LocalCacheSupplier) RoleGet(ctx context.Context, roleId string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
......@@ -82,10 +81,8 @@ func (s *LocalCacheSupplier) RoleDelete(ctx context.Context, roleId string, hint
}
func (s *LocalCacheSupplier) RolePermanentDeleteAll(ctx context.Context, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
result := s.Next().RolePermanentDeleteAll(ctx, hints...)
defer s.roleCache.Purge()
defer s.doClearCacheCluster(s.roleCache)
s.roleCache.Purge()
s.doClearCacheCluster(s.roleCache)
return result
return s.Next().RolePermanentDeleteAll(ctx, hints...)
}
......@@ -18,11 +18,10 @@ func (s *LocalCacheSupplier) handleClusterInvalidateScheme(msg *model.ClusterMes
}
func (s *LocalCacheSupplier) SchemeSave(ctx context.Context, scheme *model.Scheme, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
result := s.Next().SchemeSave(ctx, scheme, hints...)
if len(scheme.Id) != 0 {
s.doInvalidateCacheCluster(s.schemeCache, scheme.Id)
defer s.doInvalidateCacheCluster(s.schemeCache, scheme.Id)
}
return result
return s.Next().SchemeSave(ctx, scheme, hints...)
}
func (s *LocalCacheSupplier) SchemeGet(ctx context.Context, schemeId string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
......@@ -42,12 +41,10 @@ func (s *LocalCacheSupplier) SchemeGetByName(ctx context.Context, schemeName str
}
func (s *LocalCacheSupplier) SchemeDelete(ctx context.Context, schemeId string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
result := s.Next().SchemeDelete(ctx, schemeId, hints...)
s.doInvalidateCacheCluster(s.schemeCache, schemeId)
s.doClearCacheCluster(s.roleCache)
defer s.doInvalidateCacheCluster(s.schemeCache, schemeId)
defer s.doClearCacheCluster(s.roleCache)
return result
return s.Next().SchemeDelete(ctx, schemeId, hints...)
}
func (s *LocalCacheSupplier) SchemeGetAllPage(ctx context.Context, scope string, offset int, limit int, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
......
......@@ -13,7 +13,6 @@ import (
func (s *RedisSupplier) RoleSave(ctx context.Context, role *model.Role, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
key := buildRedisKeyForRoleName(role.Name)
result := s.Next().RoleSave(ctx, role, hints...)
defer func() {
if err := s.client.Del(key).Err(); err != nil {
......@@ -21,7 +20,7 @@ func (s *RedisSupplier) RoleSave(ctx context.Context, role *model.Role, hints ..
}
}()
return result
return s.Next().RoleSave(ctx, role, hints...)
}
func (s *RedisSupplier) RoleGet(ctx context.Context, roleId string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
......@@ -87,7 +86,6 @@ func (s *RedisSupplier) RoleGetByNames(ctx context.Context, roleNames []string,
}
func (s *RedisSupplier) RoleDelete(ctx context.Context, roleId string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
// XXXXXX Shouldn't this call Role
result := s.Next().RoleGet(ctx, roleId, hints...)
if result.Err == nil {
......@@ -105,17 +103,17 @@ func (s *RedisSupplier) RoleDelete(ctx context.Context, roleId string, hints ...
}
func (s *RedisSupplier) RolePermanentDeleteAll(ctx context.Context, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
result := s.Next().RolePermanentDeleteAll(ctx, hints...)
if keys, err := s.client.Keys("roles:*").Result(); err != nil {
mlog.Error("Redis encountered an error on read: " + err.Error())
} else {
if err := s.client.Del(keys...).Err(); err != nil {
mlog.Error("Redis encountered an error on delete: " + err.Error())
defer func() {
if keys, err := s.client.Keys("roles:*").Result(); err != nil {
mlog.Error("Redis encountered an error on read: " + err.Error())
} else {
if err := s.client.Del(keys...).Err(); err != nil {
mlog.Error("Redis encountered an error on delete: " + err.Error())
}
}
}
}()
return result
return s.Next().RolePermanentDeleteAll(ctx, hints...)
}
func buildRedisKeyForRoleName(roleName string) string {
......
......@@ -10,37 +10,31 @@ import (
)
func (s *RedisSupplier) SchemeSave(ctx context.Context, scheme *model.Scheme, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
result := s.Next().SchemeSave(ctx, scheme, hints...)
// TODO: Redis caching.
return result
return s.Next().SchemeSave(ctx, scheme, hints...)
}
func (s *RedisSupplier) SchemeGet(ctx context.Context, schemeId string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
result := s.Next().SchemeGet(ctx, schemeId, hints...)
// TODO: Redis caching.
return result
return s.Next().SchemeGet(ctx, schemeId, hints...)
}
func (s *RedisSupplier) SchemeGetByName(ctx context.Context, schemeName string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
result := s.Next().SchemeGetByName(ctx, schemeName, hints...)
// TODO: Redis caching.
return result
return s.Next().SchemeGetByName(ctx, schemeName, hints...)
}
func (s *RedisSupplier) SchemeDelete(ctx context.Context, schemeId string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
result := s.Next().SchemeDelete(ctx, schemeId, hints...)
// TODO: Redis caching.
return result
return s.Next().SchemeDelete(ctx, schemeId, hints...)
}
func (s *RedisSupplier) SchemeGetAllPage(ctx context.Context, scope string, offset int, limit int, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
result := s.Next().SchemeGetAllPage(ctx, scope, offset, limit, hints...)
// TODO: Redis caching.
return result
return s.Next().SchemeGetAllPage(ctx, scope, offset, limit, hints...)
}
func (s *RedisSupplier) SchemePermanentDeleteAll(ctx context.Context, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
result := s.Next().SchemePermanentDeleteAll(ctx, hints...)
// TODO: Redis caching.
return result
return s.Next().SchemePermanentDeleteAll(ctx, hints...)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment