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

[cart] use 60m TTL for cart cache #779

Merged
merged 6 commits into from
Mar 15, 2023
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
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