memcachedãæå»å·»ãæ»ãã«å¼·ããã¦ã¿ã
æ¨æ¥ã®ããµã失æã¨ã³ããªã注ç®ãéãã¦ããããã§æ¥ãããããâ¦
ä»å¾ããµã失æã§å°ããªãããã«ãmemcachedã®ããããæ¸ãã¦ã¿ããã¨æã£ãã
æéãå·»ãæ»ã£ãç¬éã«é害ãåºãã®ã¯ãããããªããã©ã
å·»ãæ»ã£ããã¨ã«ãã®å½±é¿ãæ®ãç¶ããã®ã¯å¬ãããªãã
æ¨æ¥èµ·ããç¾è±¡ãèããã«ã
ãmemcachedå
é¨ã§ã®æéã¯ã絶対æéã§ä¿æãã¦ããã®ã§ã¯ãªãèµ·åæéããã®ç¸å¯¾æéã§ä¿æããã¦ãããã®ã ãããã¨äºæ³ãã¦ãããå®éããã¿ããã
current_timeã¨ããå¤æ°ã«ãç¾å¨ã®èµ·åæéããã®ç¸å¯¾ç§ãè¨é²ããã¦ããï¼set_curent_time()ï¼ã
realtime()ã§ã¯ãå種ã³ãã³ãã§ä¸ããããexptimeãèµ·åæéããã®ç¸å¯¾ç§ã«å¤æãã¦ããã
#define REALTIME_MAXDELTA 60*60*24*30 typedef unsigned int rel_time_t; /* time-sensitive callers can call it by hand with this, outside the normal ever-1-second timer */ static void set_current_time(void) { struct timeval timer; gettimeofday(&timer, NULL); current_time = (rel_time_t) (timer.tv_sec - stats.started); } 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 <= stats.started) return (rel_time_t)1; return (rel_time_t)(exptime - stats.started); } else { return (rel_time_t)(exptime + current_time); } }
ã¾ãæãã¤ãææ³ã¯ãrel_time_tåã®å¤æ°ã«ã¤ãã¦ãå
¨é¨çµ¶å¯¾ç§ã«å¤ããææ³ã
time_tã®åã§ãã__TIME_T_TYPEã¯long intãã
絶対æéãæ¡ç¨ããã¨LP64ã§ã¯ãµã¤ãºã2åã«ãªããããã¯ä½¿ããã¼ã
ããããã絶対ç§ã«ããã¨ä¿®æ£ç¹ãå¤ãããã
ã¨ããããã§ãset_current_timeã以ä¸ã®ããã«å¤ãã¦ã¿ãã
æéã®å·»ãæ»ããæ¤åºããããæ¤åºæã®æéãèµ·åæéã«è¨å®ãããã¨ããè¶
æ³¥ç¸ã
åå²äºæ¸¬ãå¹ãããå®è¡é度ã¸ã®å½±é¿ãå°ãªãã
2ç§ãããã¦ããã®ã¯ãç¸å¯¾æé0ãç¹å¥ãªæå³ãæã¤ããã£ãã
/* time-sensitive callers can call it by hand with this, outside the normal ever-1-second timer */ static void set_current_time(void) { struct timeval timer; gettimeofday(&timer, NULL); if (timer.tv_sec < stats.started) { stats.started = timer.tv_sec - 2; } current_time = (rel_time_t) (timer.tv_sec - stats.started); }
æéãããã£ã¡ãè¨å®ãã¦ããã°ã
- æ®çºããã¨ãããªãã«ããºã
- æ°¸ç¶åããã»ã©ã§ããªã
- é«ã¹ã«ã¼ããããè¦æ±ããã
- ãããã¯ã¼ã¯è¶ãã§åç §ããã
æ
å ±ã«ã¤ãã¦ä¿æããããã«ãrepcachedã¯é©ãã¦ãã¾ããï¼ï¼
(ããã主ã«è¨ããã)