diff --git a/changelog.md b/changelog.md index 0eedc5a..9b21369 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased +## 1.7.0 - 2024-10-08 + +### Added + +- [#85](https://github.com/Azure/Microsoft.Extensions.Caching.Cosmos/pull/85) Increased SDK dependency version for critical fixes + +### Fixed + +- [#85](https://github.com/Azure/Microsoft.Extensions.Caching.Cosmos/pull/85) Fix another race condition with less than 1 seconds left on sliding expiration + ## 1.6.2 - 2024-08-30 ### Fixed diff --git a/src/CosmosCache.cs b/src/CosmosCache.cs index 1e9acc4..3bcc2f7 100644 --- a/src/CosmosCache.cs +++ b/src/CosmosCache.cs @@ -129,7 +129,7 @@ public byte[] Get(string key) else { double pendingSeconds = (absoluteExpiration - DateTimeOffset.UtcNow).TotalSeconds; - if (pendingSeconds == 0) + if (pendingSeconds < 1) { // Cosmos DB TTL works on seconds granularity and this item has less than a second to live. // Return the content because it does exist, but it will be cleaned up by the TTL shortly after. @@ -231,7 +231,7 @@ public void Refresh(string key) else { double pendingSeconds = (absoluteExpiration - DateTimeOffset.UtcNow).TotalSeconds; - if (pendingSeconds == 0) + if (pendingSeconds < 1) { // Cosmos DB TTL works on seconds granularity and this item has less than a second to live. // Treat it as a cache-miss. diff --git a/src/CosmosDistributedCache.csproj b/src/CosmosDistributedCache.csproj index 78beda4..2378e61 100644 --- a/src/CosmosDistributedCache.csproj +++ b/src/CosmosDistributedCache.csproj @@ -6,7 +6,7 @@ © Microsoft Corporation. All rights reserved. $([System.DateTime]::Now.ToString(yyyyMMdd)) en-US - 1.6.2 + 1.7.0 preview $(ClientVersion) $(ClientVersion)-$(VersionSuffix) @@ -40,7 +40,7 @@ - + diff --git a/tests/unit/CosmosCacheTests.cs b/tests/unit/CosmosCacheTests.cs index 4a7e096..e834229 100644 --- a/tests/unit/CosmosCacheTests.cs +++ b/tests/unit/CosmosCacheTests.cs @@ -719,7 +719,7 @@ public async Task SlidingExpirationWithAbsoluteExpirationOnReplaceNotFound() public async Task SlidingExpirationWithAbsoluteExpirationOnAlmostExpiredRead() { const int ttlSliding = 20; - const int ttlAbsolute = 500; + const int ttlAbsolute = 900; string etag = "etag"; CosmosCacheSession existingSession = new CosmosCacheSession(); existingSession.SessionKey = "key";