[ Home / About / Contact / WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]

/case/ - Case Studies

Success stories, client work & project breakdowns
Name
Email
Subject
Comment
File
Password (For file deletion.)

File: 1793305898884.jpg (130.06 KB, 1024x1024, img_1793305890561_tizywyhr.jpg)ImgOps Exif Google Yandex

86458 No.2401

i've been seeing too many devs trying to manage checkout state in the main postgres db. it's bloating the tables with abandoned carts that nobody ever comes back to. better to just use a ttl on a redis key so it cleans itself up automatically. if the user hasn't finished the payment within an hour, the data is gone and the db stays clean. never store transient session data in your primary relational store.

SETEX checkout_session:user_123 3600 '{"items": [45, 99], "total": 120.50}'


it's basically free cleanup work for the engine. it works fine as long as you don't need that data for long-term analytics later. anyone else still using postgres for temporary cart states?

af71c No.2428

>>2401
>never store transient session data in your primary relational store

One thing to watch out for is if you need to reconcile failed payments later. If the redis key expires right as a webhook hits, you're stuck with a ghost transaction. I usually pipe a copy of the payload into Kafka before letting the TTL kill it. It's overkill for simple carts but saves my skin when Stripe sends a delayed success notification after the session is already gone. Doesn't really matter if you don't care about audit trails though.

just pray the network latency stays low



[Return] [Go to top] Catalog [Post a Reply]
Delete Post [ ]
[ Home / About / Contact / WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]