liubiao4123 / servicestack

Automatically exported from code.google.com/p/servicestack
0 stars 0 forks source link

Problem with Redis ExpireEntryAt #36

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Same client connect on 2 redis servers based on windows distribution. One on 
win7 x86, second on win 2008 r2 x64.

When i do redis.ExpireEntryAt(dbKey,DateTime.Now.AddHour(1));
The key is availaible on the first, and expires immediatly on second.

When i look at redis monitor, seems the generated unixtime was now - 1h

A convert issue ? 

ExpireAt works fine

Original issue reported on code.google.com by jeanmari...@gmail.com on 31 Aug 2010 at 3:44

GoogleCodeExporter commented 8 years ago
Well the redis ExpireAt command takes a Unix time which is in UTC which is what 
the RedisClient sends.

If you're -1hr off your local time, then I'm guessing your servers are located 
in the UK?

It sounds to me that your systems time may not be in sync. I would double check 
that the client and servers are all configured with the correct time and time 
zone.

- Demis

Original comment by demis.be...@gmail.com on 31 Aug 2010 at 4:14

GoogleCodeExporter commented 8 years ago
All servers in france, same timezone, i checked this first.
The différence is in fact -2h

Expireat works fine, with a custom convert function.

Original comment by jeanmari...@gmail.com on 31 Aug 2010 at 4:42

GoogleCodeExporter commented 8 years ago
So you're saying that your own custom function to generate a unixtime works?

This is the source code of the one used in 'redis.ExpireEntryAt':

public const long UnixEpoch = 621355968000000000L;
public static long ToUnixTime(this DateTime dateTime)
{
    var epoch = (dateTime.ToUniversalTime().Ticks - UnixEpoch) / TimeSpan.TicksPerSecond;
    return epoch;
}

I'm guessing your *custom one that works* is similar but without the 
'.ToUniversalTime()'?

I just checked with #redis and they confirm its UTC.

So frances local time now is: 7:00pm
UTC is 5:00pm

Using MONITOR which value gets to redis? 

Original comment by demis.be...@gmail.com on 31 Aug 2010 at 5:04

GoogleCodeExporter commented 8 years ago
sorry, your product is ok.
here is my real problem:
http://code.google.com/p/redis/issues/detail?id=318

Original comment by jeanmari...@gmail.com on 1 Sep 2010 at 10:14

GoogleCodeExporter commented 8 years ago
Sweet, good to know.

Original comment by demis.be...@gmail.com on 1 Sep 2010 at 10:20