Answer the question
In order to leave comments, you need to log in
Redis. How to write to a TimeStamp key from the server where the Redis server is running?
It's a simple task, but I couldn't find the answer on the Internet.
The Redis server is written to from other sites on the Internet using php-rediska.
The date set on these sites naturally cannot be trusted. Second-to-second accuracy is important.
Answer the question
In order to leave comments, you need to log in
And about patching Redis, if you still decide, here is a description of the protocol . You need to create a special kind of argument, with placeholders. I would add, $PLACEHOLDER
it turns out that if after $ there is a numeric value, then this is the length of the value and we read it from a new line (that is, as it happens now). If the $ is followed by a non-numeric string, then this is a placeholder. In this case, it could be $TIMESTAMP
, which says that the argument is the current timestamp. This will also allow more placeholders to be added in the future (can't think of any though). If you need more flexibility, you can use placeholders directly in values, for example, something like %TIMESTAMP%
, but this will make the code backwards incompatible.
PS I would still look towards NTP :)
As far as I know, Redis doesn't do this. Therefore, there are such alternatives:
- do not give open access to Redis, but provide services (a rather time-consuming task and perhaps superfluous, but more correct, since there is no dependence on the backend; in fact, everything depends on the task)
- patch Redis (easier than the first, but there will be problems if the patch is not accepted: you will have to support such a feature with handles)
- set up time synchronization using an NTP client (the easiest, but if there is no root, then it is impossible to do)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question