Building a model reservation system with atomic locks @aarondfrancis
Building a model reservation system with atomic locks  @aarondfrancis
Uploaded May 2025 | Updated September 2026, 7 hours ago
We're using Laravel's atomic locks and database-generated columns to build a reliable reservation system—without race conditions or extra tables. I'll show you how to hook into Laravel’s cache lock system, add polymorphic relationships, and use generated columns to power powerful query scopes.

Atomic Locks Video: youtu.be/jGb5zIgwL4c

Follow me:
Twitter: twitter.com/aarondfrancis
LinkedIn: linkedin.com/in/aarondfrancis
Website: aaronfrancis.com - find articles, podcasts, courses, and more.

Our courses:
High Performance SQLite: highperformancesqlite.com
Mastering Postgres: masteringpostgres.com
High Leverage Rails: highleveragerails.com
Screencasting: screencasting.com

Chapters:
00:00 - What is an atomic lock?
02:00 - Two real-world locking scenarios
03:10 - Desired API design using reservation scopes
04:44 - Basic cache lock implementation
06:54 - Improving lock key visibility in database
08:34 - Moving toward database query integration
11:05 - Setting up polymorphic relationships
12:13 - Reusing Laravel’s cache_locks table
15:00 - Generating reservation keys programmatically
19:00 - Using generated columns to parse reservation keys
22:00 - Verifying morph relationship and query behavior
25:00 - Handling timing and collision issues
29:00 - Making key parsing more robust
32:00 - Filtering out expired or invalid locks
34:00 - Implementing unreserved and reserveFor scopes
38:00 - Building a reserve() method on the model
40:00 - Live testing reservation behavior
41:30 - Wrapping up: robust, multi-database reservation system
Building a model reservation system with atomic locksReact Server Components are a bad choice (for shipping)Building a serverless database replica with Carl SverreSupercharge Markdown with LaravelThe Music Makers Podcast - 027 - Twenty Six, Unmarried, and Childless.37signals almost ditched SQLite—here’s why they kept itI built a simple first-party tracking system for my adsMake your site faster with this one techniqueThe Music Makers Podcast - 024 - You Can Be Busy Or Remarkable, But Not BothLaravel vs ReactPostgres on bare metal with the CEO of PrismaRead the docs (dont skim them)
Aaron Francis |

Building a model reservation system with atomic locks

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER