1

I want to make a site with an online currency that increments every hour, or any other time frame. It's going to be retrieved from a MySQL database, no matter if the user is online or not, and then an amount is going to be added to the variable and sent back to the server again.

I've looked around but still struggling to get my head around the explanations.

Any help is greatly appreciated.

Thanks in advance!

4

1 回答 1

2

为了减少大量用户的持续数据库更新,您可以跟踪用户的创建时间并从那里计算他们应该拥有的货币数量。对于任何额外的花费/被盗/赚到的钱,您可能还必须有一个修饰符。

例子:

user1 创建于 1376936553 (时间为 unix 时间戳)

一个小时后,unix 时间将是 1376940153。如果你想知道他们应该有多少可能的货币单位,那就是

(当前时间 - 开始时间)/3600 = 1

然后,如果用户花费了这笔钱,请在单独的数据库字段中对其进行跟踪并将其应用于总数。

于 2013-08-19T17:21:35.627 回答