Skip to content

Commit

Permalink
Merge branch 'cache_expiration_baseline' into cache_expiration_valida…
Browse files Browse the repository at this point in the history
…teExpiration_method
  • Loading branch information
EmilianoSanchez committed Dec 26, 2024
2 parents 7100734 + edb8995 commit 760e2d0
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- Added two new configuration options for the SDK storage in browsers when using storage type `LOCALSTORAGE`:
- `storage.expirationDays` to specify the validity period of the rollout cache.
- `storage.clearOnInit` to clear the rollout cache on SDK initialization.
- Bugfixing - Properly handle rejected promises when using targeting rules with segment matchers in consumer modes (e.g., Redis and Pluggable storages).

2.0.2 (December 3, 2024)
- Updated the factory `init` and `destroy` methods to support re-initialization after destruction. This update ensures compatibility of the React SDK with React Strict Mode, where the factory's `init` and `destroy` effects are executed an extra time to validate proper resource cleanup.
Expand Down
7 changes: 0 additions & 7 deletions src/evaluator/matchers/large_segment.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { MaybeThenable } from '../../dtos/types';
import { ISegmentsCacheBase } from '../../storages/types';
import { thenable } from '../../utils/promise/thenable';

export function largeSegmentMatcherContext(largeSegmentName: string, storage: { largeSegments?: ISegmentsCacheBase }) {

return function largeSegmentMatcher(key: string): MaybeThenable<boolean> {
const isInLargeSegment = storage.largeSegments ? storage.largeSegments.isInSegment(largeSegmentName, key) : false;

if (thenable(isInLargeSegment)) {
isInLargeSegment.then(result => {
return result;
});
}

return isInLargeSegment;
};
}
7 changes: 0 additions & 7 deletions src/evaluator/matchers/segment.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { MaybeThenable } from '../../dtos/types';
import { ISegmentsCacheBase } from '../../storages/types';
import { thenable } from '../../utils/promise/thenable';

export function segmentMatcherContext(segmentName: string, storage: { segments: ISegmentsCacheBase }) {

return function segmentMatcher(key: string): MaybeThenable<boolean> {
const isInSegment = storage.segments.isInSegment(segmentName, key);

if (thenable(isInSegment)) {
isInSegment.then(result => {
return result;
});
}

return isInSegment;
};
}
2 changes: 1 addition & 1 deletion src/storages/inRedis/SplitsCacheInRedis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ export class SplitsCacheInRedis extends AbstractSplitsCacheAsync {
return Promise.reject(this.redisError);
}

const splits: Record<string, ISplit | null> = {};
const keys = names.map(name => this.keys.buildSplitKey(name));
return this.redis.mget(...keys)
.then(splitDefinitions => {
const splits: Record<string, ISplit | null> = {};
names.forEach((name, idx) => {
const split = splitDefinitions[idx];
splits[name] = split && JSON.parse(split);
Expand Down

0 comments on commit 760e2d0

Please sign in to comment.