-
Notifications
You must be signed in to change notification settings - Fork 34
Make CachingManager initializer public to allow external creation #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vazarkevych
merged 10 commits into
growthbook:main
from
vazarkevych:feature/stickybucketing-cachemanager
Sep 5, 2025
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
141449f
Make CachingManager initializer public to allow external creation, ad…
13a9521
update
vazarkevych 54bf3db
Merge remote-tracking branch 'origin/main' into feature/stickybucketi…
cbaae21
update testcases json file
1e2344e
fix hash tests
7a95cd2
add query string functionality
872ad94
refactor isEvalOperatorCondition function
4393cfb
make rule id as empty string
b10e25c
fix StickyBucket service init with cache key, and reuse EvalContext t…
3362db1
fix stickybucket refresh functionalty, add function getGBAttributes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,23 +8,18 @@ import Foundation | |
|
|
||
| @objc public class StickyBucketService: NSObject, StickyBucketServiceProtocol { | ||
| private let prefix: String | ||
| private let localStorage: CachingLayer? | ||
| private let localStorage = CachingManager() | ||
|
|
||
| public init(prefix: String = "gbStickyBuckets__", localStorage: CachingLayer? = nil) { | ||
| public init(prefix: String = "gbStickyBuckets__", localStoragePath: CacheDirectory = .applicationSupport) { | ||
| self.prefix = prefix | ||
| self.localStorage = localStorage | ||
| localStorage.setSystemCacheDirectory(localStoragePath) | ||
| } | ||
|
|
||
| public func getAssignments(attributeName: String, | ||
| attributeValue: String, | ||
| completion: @escaping (StickyAssignmentsDocument?, Error?) -> Void) { | ||
| let key = "\(attributeName)||\(attributeValue)" | ||
|
|
||
| guard let localStorage = localStorage else { | ||
| completion(nil, nil) | ||
| return | ||
| } | ||
|
|
||
| if | ||
| let data = localStorage.getContent(fileName: prefix + key), | ||
| let jsonPetitions = try? JSONDecoder().decode(StickyAssignmentsDocument.self, from: data) { | ||
|
|
@@ -39,12 +34,9 @@ import Foundation | |
| completion: @escaping (Error?) -> Void) { | ||
| let key = "\(doc.attributeName)||\(doc.attributeValue)" | ||
|
|
||
| guard let localStorage = localStorage, | ||
| let docData = try? JSONEncoder().encode(doc) else { | ||
| completion(nil) | ||
| return | ||
| } | ||
|
|
||
|
|
||
| guard let docData = try? JSONEncoder().encode(doc) else { return } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vazarkevych I think we need to call
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
|
|
||
| localStorage.saveContent(fileName: prefix + key, content: docData) | ||
| completion(nil) | ||
| } | ||
|
|
@@ -65,12 +57,8 @@ import Foundation | |
|
|
||
| private func getAssignmentsSync(attributeName: String, attributeValue: String) -> StickyAssignmentsDocument? { | ||
| let key = "\(attributeName)||\(attributeValue)" | ||
|
|
||
| guard let localStorage = localStorage else { return nil } | ||
|
|
||
| if | ||
| let data = localStorage.getContent(fileName: prefix + key), | ||
| let jsonPetitions = try? JSONDecoder().decode(StickyAssignmentsDocument.self, from: data) { | ||
|
|
||
| if let data = localStorage.getContent(fileName: prefix + key), let jsonPetitions = try? JSONDecoder().decode(StickyAssignmentsDocument.self, from: data) { | ||
| return jsonPetitions | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we need to set
cacheKeysomehow?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done