SimpleDB 插入时的时间戳
我正在 iPhone 上开发一款游戏,该游戏将使用 SimpleDB 进行游戏数据存储,并且我希望能够使某些数据库条目超时。
我想我将有一些 cron 作业来查看每个条目的时间戳,如果它的增量大于 X,我将超时该条目(更改其中的 var,以便它再次可供用户选择)。
我的问题是我不知道如何统一时间戳。如果用户的系统时钟搞砸了,并且偏差了几个小时甚至几天,我该怎么办?我想要的是在插入时从 SimpleDB 服务器获取系统时间,但我相信我读到 SimpleDB 不提供任何类型的时间戳。
我当前唯一的想法是让所有客户端在启动时从某个随机在线源获取时间戳,然后根据该时间和系统滴答确定时间戳,但我真的更喜欢将其保留在我的程序和AWS服务器内部,因为我无法保证第三方时间戳源将提供什么以及何时提供。
任何人都可以建议此问题的解决方案,或者提醒我由 AWS 服务器维护的可访问时间戳吗?我仍处于设计阶段,所以我没有对 AWS 消息做太多工作,它们的响应数据包是否可能包含某处的时间?
谢谢! -斯凯勒
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的建议是让一个中间 Web 服务(可能位于 EC2 实例上)处理 iPhone 应用程序和 SimpleDB 之间的所有通信。
这解决了您迫在眉睫的问题,因为现在中间 Web 服务器可以添加一致的时间戳。
但是......更重要的是,这解决了如何使用 AWS 密钥的安全问题(现在它们位于您控制的服务器上)。您真的不想将它们嵌入您的 iPhone 应用程序中...:-)
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... :-)
同意 Scrappydog 的观点 - 无论如何,您可能需要中间件来保护您的 AWS 密钥。请查看:
https://github.com/apetresc/awskeyserver
进行概念验证解决方案。这使用了GAE,我相信它也可以为您提供稳定的时间源。
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.