Changeset 438 for branches/performance
- Timestamp:
- 11/20/06 22:05:31 (3 years ago)
- Location:
- branches/performance/server
- Files:
-
- 4 modified
-
items.c (modified) (1 diff)
-
memcached.c (modified) (3 diffs)
-
memcached.h (modified) (1 diff)
-
t/flush-all.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/performance/server/items.c
r419 r438 330 330 return buf; 331 331 } 332 333 /* expires items that are more recent than the oldest_live setting. */ 334 void item_flush_expired() { 335 int i; 336 item *iter, *next; 337 if (! settings.oldest_live) 338 return; 339 for (i = 0; i < LARGEST_ID; i++) { 340 /* The LRU is sorted in decreasing time order, and an item's timestamp 341 * is never newer than its last access time, so we only need to walk 342 * back until we hit an item older than the oldest_live time. 343 * The oldest_live checking will auto-expire the remaining items. 344 */ 345 for (iter = heads[i]; iter != NULL; iter = next) { 346 if (iter->time >= settings.oldest_live) { 347 next = iter->next; 348 if ((iter->it_flags & ITEM_SLABBED) == 0) { 349 item_unlink(iter); 350 } 351 } else { 352 /* We've hit the first old item. Continue to the next queue. */ 353 break; 354 } 355 } 356 } 357 } -
branches/performance/server/memcached.c
r421 r438 97 97 stats.curr_bytes = stats.bytes_read = stats.bytes_written = 0; 98 98 99 /* make the time we started always be 1 secondbefore we really99 /* make the time we started always be 2 seconds before we really 100 100 did, so time(0) - time.started is never zero. if so, things 101 101 like 'settings.oldest_live' which act as booleans as well as 102 102 values are now false in boolean context... */ 103 stats.started = time(0) - 1;103 stats.started = time(0) - 2; 104 104 } 105 105 … … 1338 1338 1339 1339 if(ntokens == 2) { 1340 settings.oldest_live = current_time; 1340 settings.oldest_live = current_time - 1; 1341 item_flush_expired(); 1341 1342 out_string(c, "OK"); 1342 1343 return; … … 1349 1350 } 1350 1351 1351 settings.oldest_live = realtime(exptime); 1352 settings.oldest_live = realtime(exptime) - 1; 1353 item_flush_expired(); 1352 1354 out_string(c, "OK"); 1353 1355 return; -
branches/performance/server/memcached.h
r419 r438 277 277 char *item_stats_sizes(int *bytes); 278 278 void item_stats(char *buffer, int buflen); 279 void item_flush_expired(void); 279 280 280 281 /* time handling */ -
branches/performance/server/t/flush-all.t
r347 r438 2 2 3 3 use strict; 4 use Test::More tests => 1 1;4 use Test::More tests => 10; 5 5 use FindBin qw($Bin); 6 6 use lib "$Bin/lib"; … … 17 17 print $sock "flush_all\r\n"; 18 18 is(scalar <$sock>, "OK\r\n", "did flush_all"); 19 mem_get_is($sock, "foo", undef); 19 20 20 mem_get_is($sock, "foo", undef); 21 SKIP: { 22 skip "flush_all is still only second-granularity. need atomic counter on flush_all.", 2 unless 0; 23 24 print $sock "set foo 0 0 3\r\nnew\r\n"; 25 is(scalar <$sock>, "STORED\r\n", "stored foo = 'new'"); 26 mem_get_is($sock, "foo", 'new'); 27 } 28 29 sleep 1; 30 mem_get_is($sock, "foo", undef); 21 # check that flush_all doesn't blow away items that immediately get set 22 print $sock "set foo 0 0 3\r\nnew\r\n"; 23 is(scalar <$sock>, "STORED\r\n", "stored foo = 'new'"); 24 mem_get_is($sock, "foo", 'new'); 31 25 32 26 # and the other form, specifying a flush_all time...
