Skip to content

Commit

Permalink
Bring cachingEnabled check outside barrier
Browse files Browse the repository at this point in the history
  • Loading branch information
NQuinn27 committed Oct 2, 2024
1 parent 9444f84 commit 6572eab
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class ConfigurationCache: ConfigurationCaching {
}

func data(forKey key: String) -> ConfigurationCachedData? {
Self.queue.sync(flags: .barrier) { [weak self] in
guard let self = self,
cachingEnabled else {
guard cachingEnabled else { return nil }
return Self.queue.sync(flags: .barrier) { [weak self] in
guard let self = self else {
return nil
}
if let cachedData = cache.value(forKey: key) {
Expand All @@ -39,8 +39,9 @@ class ConfigurationCache: ConfigurationCaching {
}

func setData(_ data: ConfigurationCachedData, forKey key: String) {
Self.queue.sync(flags: .barrier) { [weak self] in
guard let self = self, cachingEnabled else {
guard cachingEnabled else { return }
return Self.queue.sync(flags: .barrier) { [weak self] in
guard let self = self else {
return
}
// Cache includes at most one cached configuration
Expand Down

0 comments on commit 6572eab

Please sign in to comment.