问题
I am working on a game on the iPhone that will use SimpleDB for game data storage and I'd like to be able to timeout some database entries.
I figure i'll have some cron job that looks at the timestamp of each entry and if it's delta is greater than X i'll time out that entry(change a var in it so it is once again available for selection by users).
My issue is i don't know how to unify the timestamps. What do i do if a user has their system clock screwed up and it's off by a couple hours or even days? What i'd like is to get the system time from the SimpleDB servers when i insert, but i believe i read that SimpleDB doesn't provide any sort of timestamp.
My only current thought is to have all clients get a timestamp from some random online source at start up and then determine timestamps based off that time and system ticks, but i'd really prefer keeping this internal to my program and the AWS servers as i can't guarantee what the 3rd party timestamp source would be provide and when.
Can anyone suggest a solution to this issue or perhaps alert me to an accessible timestamp that is maintained by the AWS servers? I'm still in the design phase so i haven't done much work with the AWS messages, do their response packets maybe contain the time somewhere?
Thanks! -Skyler
回答1:
My recommendation would be to have an intermediate webservice (probably sitting on an EC2 instance) handle all the communication between your iPhone app and SimpleDB.
This solves your immeadiate question because now the intermediate web server can add a consistent timestamp.
But... more importantly this solves the security problem of what to with you AWS keys (now they are living on a server you control). You really don't want to have them embedded in your iPhone app... :-)
回答2:
Agree with Scrappydog - you'll probably need middleware to secure your AWS keys anyways. Take a look at:
https://github.com/apetresc/awskeyserver
for a proof-in-concept solution. This uses GAE, which can also supply you a stable time source I'm sure.
来源:https://stackoverflow.com/questions/5285595/simpledb-timestamp-on-insert