php - Atomic/safe serving of single-use codes -
i have list of single-use discount codes ecommerce site i'm partnering with. need set page on site users can fill out form, , given 1 of codes. codes pre-determined , have been sent me in text file; can't generate them on fly. need figure out best way unused code list, , remove list (or update flag mark used) @ same time, avoid possibility of giving 2 people same code. in other words, similar queue, can remove 1 item queue atomically.
this webapp running on aws , current code python (though potentially use else if necessary; php easy). ideally i'd use 1 of aws services or mysql this, i'm open other solutions if they're not royal pain integrated. since thought "queue," sqs popped head, not it's intended (e.g. 14 day limit on messages remaining in queue not work me). while i'm expecting modest traffic (which means hacky solutions work), i'd rather learn right way @ scale.
i cant give actual code examples, 1 of easiest ways increment counter in file,
0 code1 code2 code3 etc
and skipping many lines every time code used.
you pretty in database
Comments
Post a Comment