Implement the caching mechanism for the publisher restrictions in TCData
class
#4
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.
Description
To implement the caching mechanism we introduce in the IAB TCF
cmpapi
library two new classes:CacheBucket
andCache
.The
CacheBucket
class implements actual caching mechanism and providesget
method that accepts cache key, recalculation function and recalculation functions parameters as arguments. TheCacheBucket
class also has aname
property.The
Cache
class implements a collection (map) ofCacheBucket
objects with several simple methods including thegetBucket
method to get/createCacheBucket
using name string.We need this two level structure to separate caching for two classes
TCData
andInAppTCData
.We use
Cache
class to createrestrictionsCache
inCmpApiModel
singleton class that "... acts much like a global state or database, where CmpApi sets data and Commands read the data".The
TCData
class usesrestrictionsCache
to get cachebucket
using class nameNow the publisher
restrictions
could be extracted from theCacheBucket
or recalculated if consent string value is changedSummary of changes
CacheBucket
class implemented;Cache
class implemented;CmpApiModel
class (singleton) to addrestrictionsCache
parameter;TCData
class to use restrictions cache from the singleton objectCmpApiModel
;