Tag:php
Article From:https://segmentfault.com/q/1010000012147555
Question:

In the case of the question:
How to design a point like statistical function can only be clicked once a day without landing status.

I control people by cookie. I can only click once a day.

If the cache is empty, bug visitors will click again.
How to design?

If IP is controlled, it needs to be stored in the database. Is there any other optimal solution?

Answer 0:

Precondition:No landing state
As you say, pass throughcookie Control is defective.
Suggestion:
This time – dependent operation can be usedredis There is no need to persist storage for a class of caching.
Of course, back-end storage, whether persistent or not, requires client’s credentials.IP

Programme:
redis Store the day’s point of praiseIP Set, if it’s in the set, limit the point.
At zero every day, empty the collection and record it again.

Reference: redis-set

Answer 1:

Experience told me. Without login, there is no unique identifier. (IP is not the only identification). It’s really not a limit.

They are all ordinary users.

Answer 2:

Add the time stamp of the day time to the user ID, and then store it directly to the corresponding field of user.
$date = md5(strtotime(date(‘Y-m-d’)). $id);

When the user clicks again, the front end is regenerated once, compared with the back end. If it is different, it is not the day date (this is not done the day before), directly into the database;

This method can handle, of course, record state directly in the user table.

But there are problems in the two ways and a better solution.

—Split line –

No see“Unregistered state “
Well, it’s all a shit,
The problem has been transformed into “how to give it in an unlogged state”.Each userA unique logo? ” ;
In short, it is similar to the kind of Jingdong that does not log in to the shopping cart, even if switching users, it can also know who the users are.
The answer is: No;

Answer 3:

It feels that the key point of this problem is identity confirmation, whether it is in cookie or through the IP limit, and cookie can be clear. As for IP, we get an export IP (a route may have multiple computers, but their export IP is the same, “Are these different computers one or more?
It should be decided by the business, what is called an independent user through the business, and if the data reliability requirements are high, it is better to log in and hope to help you.

Answer 4:

These are generally written in redis, simple with uid as key, value = 1, indicating that it has been praised. TTL is set to a timestamp of 24 points today.

Answer 5:

To fully control, you have to record the user’s unique identifier on the server side.

Answer 6:

If you want to know if this person has any praise, you must have something to store.
This state can be placed on the front end of cookie, which can store back-end data, and the deeper point is to store it with other synchronous states.
Well, is this state of your praise synchronized with other states? For example, a point of praise this user today is more than a sign, such as a sign, you can rely on this sign to judge whether a point of praise, this is the use of the symbol storage state.
There must be something to save anyway.

Answer 7:

Regardless of cookie or IP, the most important thing is to look at the object of your function, the object is ordinary users, cookie is enough.

Answer 8:

The reliability of this cookie or IP is not high. If others use the bulk agent IP to request, they can still brush data.

Answer 9:

No, only a limited limit.

Answer 10:

If there are no landings, how do we judge “everyone”? Everyone here should refer to every user. The user’s daily evaluation state must be judged and stored. So, I didn’t think of a good way to do it.

Leave a Reply

Your email address will not be published. Required fields are marked *