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: only delete endpoint which has expired in EndpointCache #3752

Merged
merged 2 commits into from
May 5, 2021

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented May 5, 2021

Fixes: #3750

Testing

Code:

import AWS from "../aws-sdk-js/index.js";

const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

const endpointCache = new AWS.EndpointCache(1000);
endpointCache.put("key", [
  // First endpoint expires in 3 seconds
  { Address: "expires-in-3-seconds", CachePeriodInMinutes: 0.05 },
  // First endpoint expires in 6 seconds
  { Address: "expires-in-6-seconds", CachePeriodInMinutes: 0.1 },
]);

// prints both endpoints
console.log(endpointCache.get("key"));

// Wait for 4 seconds.
await sleep(4000);
// prints endpoint "expires-in-6-seconds"
console.log(endpointCache.get("key"));

await sleep(3000);
// prints undefined
console.log(endpointCache.get("key"));

Output:

[
  { Address: 'expires-in-3-seconds', Expire: 1620242995498 },
  { Address: 'expires-in-6-seconds', Expire: 1620242998498 }
]
[ { Address: 'expires-in-6-seconds', Expire: 1620242998498 } ]
undefined
Checklist
  • changelog is added, npm run add-change

@trivikr trivikr requested a review from AllanZhengYP May 5, 2021 19:39
@trivikr trivikr merged commit 18ac9eb into aws:master May 5, 2021
@trivikr trivikr deleted the fix-endpoint-cache-evict branch May 5, 2021 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EndpointCache evicts the entire cache entry when one of the Endpoint expires
2 participants