Skip to content
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

fix: add NotSet path for increase/decrease ttl apis #1447

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/client-sdk-nodejs/src/internal/cache-data-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4541,6 +4541,8 @@ export class CacheDataClient implements IDataClient {
(err, resp) => {
if (resp?.missing) {
resolve(new CacheIncreaseTtl.Miss());
} else if (resp?.not_set) {
resolve(new CacheIncreaseTtl.NotSet());
} else if (resp?.set) {
resolve(new CacheIncreaseTtl.Set());
} else {
Expand Down Expand Up @@ -4600,6 +4602,8 @@ export class CacheDataClient implements IDataClient {
(err, resp) => {
if (resp?.missing) {
resolve(new CacheDecreaseTtl.Miss());
} else if (resp?.not_set) {
resolve(new CacheDecreaseTtl.NotSet());
} else if (resp?.set) {
resolve(new CacheDecreaseTtl.Set());
} else {
Expand Down
4 changes: 4 additions & 0 deletions packages/client-sdk-web/src/internal/cache-data-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4422,6 +4422,8 @@ export class CacheDataClient<
(err, resp) => {
if (resp?.getMissing()) {
resolve(new CacheIncreaseTtl.Miss());
} else if (resp?.getNotSet()) {
resolve(new CacheIncreaseTtl.NotSet());
} else if (resp?.getSet()) {
resolve(new CacheIncreaseTtl.Set());
} else {
Expand Down Expand Up @@ -4489,6 +4491,8 @@ export class CacheDataClient<
(err, resp) => {
if (resp?.getMissing()) {
resolve(new CacheDecreaseTtl.Miss());
} else if (resp?.getNotSet()) {
resolve(new CacheDecreaseTtl.NotSet());
} else if (resp?.getSet()) {
resolve(new CacheDecreaseTtl.Set());
} else {
Expand Down
12 changes: 6 additions & 6 deletions packages/common-integration-tests/src/cache/update-ttl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export function runUpdateTtlTest(
expect(ttlResult.remainingTtlMillis()).toBeGreaterThan(15000);
});

it('should Error if given TTL is less than current TTL', async () => {
it('should NotSet for increaseTTL if given TTL is less than current TTL', async () => {
const cacheKey = v4();
await cacheClient.set(integrationTestCacheName, cacheKey, cacheKey, {
ttl: 10,
Expand All @@ -154,8 +154,8 @@ export function runUpdateTtlTest(
5000
);
expectWithMessage(() => {
expect(response).toBeInstanceOf(CacheIncreaseTtl.Error);
}, `expected ERROR but got ${response.toString()}`);
expect(response).toBeInstanceOf(CacheIncreaseTtl.NotSet);
}, `expected NOT_SET but got ${response.toString()}`);
});

it('should Error if given a TTL below 0', async () => {
Expand Down Expand Up @@ -241,7 +241,7 @@ export function runUpdateTtlTest(
expect(ttlResult.remainingTtlMillis()).toBeGreaterThan(0);
});

it('should Error if given TTL is greater than current TTL', async () => {
it('should NotSet for decreaseTTL if given TTL is greater than current TTL', async () => {
const cacheKey = v4();
await cacheClient.set(integrationTestCacheName, cacheKey, cacheKey, {
ttl: 10,
Expand All @@ -253,8 +253,8 @@ export function runUpdateTtlTest(
20000
);
expectWithMessage(() => {
expect(response).toBeInstanceOf(CacheDecreaseTtl.Error);
}, `expected ERROR but got ${response.toString()}`);
expect(response).toBeInstanceOf(CacheDecreaseTtl.NotSet);
}, `expected NOT_SET but got ${response.toString()}`);
});

it('should Error if given a TTL below 0', async () => {
Expand Down
Loading