Order Cache and Distributed Locks
Redis-backed coordination and caching slice owned by the Ordering bounded context for buyer-scoped creation locks, HTTP idempotency markers, and cached order summaries.
Purpose & Ownership Boundary
Order Cache and Distributed Locks is the non-authoritative Redis coordination and caching slice owned exclusively by Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle,
creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs in the Ordering bounded context. Redis was chosen to provide low-latency distributed locking for concurrent checkout serialization, atomic HTTP SET NX idempotency markers, and FusionCache L2 + backplane caching across service replicas.
Data Store Profile
| Property | Value |
|---|---|
| Bounded Context / Owner | Ordering — Commerce Fulfillment TeamTeamCommerce Fulfillment TeamStream-Aligned team owning customer shopping baskets, checkout coordination, order lifecycle, and financial saga orchest...Open docs |
| Engine / Technology | Redis + FusionCache (Azure Managed Redis in cloud; Redis container locally) |
| Store Type | Cache |
| Primary Writer(s) | Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle, creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs |
| Primary Reader(s) | Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle, creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs |
| Authoritative / Source of Truth | Ephemeral (permanent orders live in Order DatabaseContainerv1.0.0Order DatabaseAuthoritative PostgreSQL system of record owned by the Ordering bounded context for buyers, accepted orders, purchase-ti...Ownercommerce-fulfillment-teamDiagramOpen docs) |
| Data Classification | Internal |
| Retention / TTL Policy | Transient (all keys expire by TTL or explicit release) |
Logical Data Layout & Key Patterns
| Key Pattern | Stored Data | TTL / Eviction | Invalidation / Update Trigger |
|---|---|---|---|
order-create:{BuyerId} (ordering lock) | Distributed creation lock handle | 1 minute acquisition timeout | Released explicitly in finally after committing the order unit of work. |
{HTTP method}:{request path}:{x-request-id} | Atomic HTTP idempotency marker (id, name, time) via SET NX | 1 hour (3,600 seconds) | Retained on 2xx/4xx responses; deleted immediately on unhandled exceptions or 5xx errors so clients can retry. |
books:{sorted book IDs} | Cached Catalog gRPC book/price batch responses | 30 minutes default (books, catalog tags) | TTL expiration or tag invalidation. |
ordering:dashboard:v1 | Aggregated Ordering and Catalog admin dashboard metrics | 15 seconds | Time-based TTL expiration. |
ordering:summary:v1:{orderId}:v{version} | Versioned order summary projection | 30 minutes default | Immutable per version; expires by TTL. |
ordering:summary:v1:{orderId}:terminal | Terminal-state order summary view | 1 hour (L1 & L2) | Cached only for terminal orders; expires by TTL. |
ordering:history:v1:{orderId}:terminal | Terminal-state order event history | 1 hour (L1 & L2) | Cached only for terminal orders; expires by TTL. |
| Integration idempotency keys | 24-hour Kafka message deduplication markers | 24 hours | Automatic TTL expiration after consumer processing. |
Consistency, Isolation & Security Guardrails
- Buyer-scoped lock boundaries: Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle,
creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs reads the basket and resolves Catalog prices before acquiring
order-create:{BuyerId}, keeping the critical section scoped strictly to order creation and persistence. The lock does not replace the PostgreSQL row-version concurrency token. - Atomic HTTP idempotency (
POST/PATCH): Requests without a non-emptyx-request-idheader are rejected (400 Bad Request), and duplicate in-flight or completed requests return409 Conflict. - Non-authoritative for purchases: Accepted orders and checkout-time prices are always committed to Order DatabaseContainerv1.0.0Order DatabaseAuthoritative PostgreSQL system of record owned by the Ordering bounded context for buyers, accepted orders, purchase-ti...Ownercommerce-fulfillment-teamDiagramOpen docs.
Shared Redis Key-Prefix & Flush Isolation: Order Cache shares the redis cluster with Basket DatabaseContainerv1.0.0Basket DatabaseAuthoritative Redis key-value store owned by the Shopping bounded context for customer-scoped pre-checkout shopping bask...Ownercommerce-fulfillment-teamDiagramOpen docs, Catalog CacheContainerv1.0.0Catalog CacheNon-authoritative FusionCache and Redis caching layer owned by the Catalog bounded context for fast book detail lookups ...Ownercatalog-experience-teamDiagramOpen docs, Rating CacheContainerv1.0.0Rating CacheNon-authoritative FusionCache and Redis caching layer owned by the Reviews bounded context for AI-generated book feedbac...Ownercatalog-experience-teamDiagramOpen docs, and Notification idempotency markers. Flushing the shared Redis instance does not delete persisted orders in orderingdb, but it drops active HTTP idempotency markers, releases in-flight creation locks, and erases active customer baskets in Basket DatabaseContainerv1.0.0Basket DatabaseAuthoritative Redis key-value store owned by the Shopping bounded context for customer-scoped pre-checkout shopping bask...Ownercommerce-fulfillment-teamDiagramOpen docs.
Operational & Resilience Notes
- Local vs. Cloud: Local development runs a persistent single-container Redis instance with
RedisInsight; cloud environments run Azure Managed Redis (
BalancedB0in Dev,BalancedB1with HA in Staging,BalancedB5with HA in Production). - Availability impact: While non-authoritative for durable order history, Redis availability directly governs concurrent checkout serialization and duplicate-request protection across Ordering replicas.
Architecture Visualizations
Loading graph...
Related Documentation
- Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle, creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs — Owning service endpoints, gRPC clients, and order creation flow.
- Order DatabaseContainerv1.0.0Order DatabaseAuthoritative PostgreSQL system of record owned by the Ordering bounded context for buyers, accepted orders, purchase-ti...Ownercommerce-fulfillment-teamDiagramOpen docs — Authoritative PostgreSQL store for buyers, orders, and event streams.
- Basket DatabaseContainerv1.0.0Basket DatabaseAuthoritative Redis key-value store owned by the Shopping bounded context for customer-scoped pre-checkout shopping bask...Ownercommerce-fulfillment-teamDiagramOpen docs — Sibling workload on the shared Redis resource.
- Backup, Restore & Disaster Recovery (DR)Custom DocBackup, Restore & Disaster Recovery (DR)Operator runbook for PostgreSQL point-in-time restore, Cosmos DB failover verification, Blob Storage recovery, and Qdran...Ownerplatform-engineering-teamOpen doc — Platform backup, restore, and disaster recovery runbook.