Skip to content

Commit

Permalink
[cart] use 60m TTL for cart cache (open-telemetry#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
puckpuck authored and juliangiuca committed Apr 12, 2023
1 parent 163f746 commit aa78c24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ release.

* spanmetrics dashboard service&operation rates%latencies
([#787](https://github.com/open-telemetry/opentelemetry-demo/pull/787))
* [cart] use 60m TTL for cart entries in redis
([#779](https://github.com/open-telemetry/opentelemetry-demo/pull/779))

## v0.1.0

Expand Down
2 changes: 2 additions & 0 deletions src/cartservice/src/cartstore/RedisCartStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public async Task AddItemAsync(string userId, string productId, int quantity)
}

await db.HashSetAsync(userId, new[]{ new HashEntry(CART_FIELD_NAME, cart.ToByteArray()) });
await db.KeyExpireAsync(userId, TimeSpan.FromMinutes(60));
}
catch (Exception ex)
{
Expand All @@ -166,6 +167,7 @@ public async Task EmptyCartAsync(string userId)

// Update the cache with empty cart for given user
await db.HashSetAsync(userId, new[] { new HashEntry(CART_FIELD_NAME, emptyCartBytes) });
await db.KeyExpireAsync(userId, TimeSpan.FromMinutes(60));
}
catch (Exception ex)
{
Expand Down

0 comments on commit aa78c24

Please sign in to comment.