- #define REALTIME_MAXDELTA 60*60*24*30
- /*
- * given time value that's either unix time or delta from current unix time, return
- * unix time. Use the fact that delta can't exceed one month (and real time value can't
- * be that low).
- */
- static rel_time_t realtime(const time_t exptime) {
- /* no. of seconds in 30 days - largest possible delta exptime */
- if (exptime == 0) return 0; /* 0 means never expire */
- if (exptime > REALTIME_MAXDELTA) {
- /* if item expiration is at/before the server started, give it an
- expiration time of 1 second after the server started.
- (because 0 means don't expire). without this, we'd
- underflow and wrap around to some large value way in the
- future, effectively making items expiring in the past
- really expiring never */
- if (exptime <= process_started)
- return (rel_time_t)1;
- return (rel_time_t)(exptime - process_started);
- } else {
- return (rel_time_t)(exptime + current_time);
- }
- }
现在也有很多人将它作为内存式数据库在使用,memcached通过它的自定义协议与客户端交互,而XMemcached就是它的一个java客户端实现。
关于XMemcached详细说明,参考.htmXMemcached简介