Fossil SCM

More administrative functions related to the Web Cache are now available on the /cachestat page.

drh 2025-04-09 12:25 trunk
Commit cfb716fb83c0e1c3797a7af0d94a8967212596ec3856de6d95d8d555f00e5b9e
1 file changed +27 -10
+27 -10
--- src/cache.c
+++ src/cache.c
@@ -418,10 +418,15 @@
418418
@ The web-page cache is disabled for this repository
419419
@ <input type="submit" name="init" value="Enable">
420420
@ </form>
421421
}else{
422422
char *zDbName = cacheName();
423
+ int nEntry = 0;
424
+ int mxEntry = 0;
425
+ if( P("clearcache")!=0 && cgi_csrf_safe(2) ){
426
+ sqlite3_exec(db, "DELETE FROM cache; DELETE FROM blob; VACUUM;",0,0,0);
427
+ }
423428
cache_register_sizename(db);
424429
pStmt = cacheStmt(db,
425430
"SELECT key, sz, nRef, datetime(tm,'unixepoch')"
426431
" FROM cache"
427432
" ORDER BY (tm + 3600*min(nRef,48)) DESC"
@@ -438,26 +443,38 @@
438443
if( zHash ){
439444
@ %z(href("%R/timeline?c=%S",zHash))check-in</a>\
440445
fossil_free(zHash);
441446
}
442447
@ </p></li>
443
-
448
+ nEntry++;
444449
}
445450
sqlite3_finalize(pStmt);
446451
@ </ol>
447452
}
448453
zDbName = cacheName();
449454
bigSizeName(sizeof(zBuf), zBuf, file_size(zDbName, ExtFILE));
450
- @ <p>
451
- @ cache-file name: %h(zDbName)<br>
452
- @ cache-file size: %s(zBuf)<br>
453
- @ max-cache-entry: %d(db_get_int("max-cache-entry",10))
454
- @ </p>
455
- @ <p>
456
- @ Use the "<a href="%R/help?cmd=cache">fossil cache</a>" command
457
- @ on the command-line to create and configure the web-cache.
458
- @ </p>
455
+ mxEntry = db_get_int("max-cache-entry",10);
456
+ @ <p>
457
+ @ </p>
458
+ @ <h2>About The Web-Cache</h2>
459
+ @ <p>
460
+ @ The web-cache is a separate database file that holds cached copies
461
+ @ tarballs, ZIP archives, and other pages that are expensive to compute
462
+ @ and are likely to be reused.
463
+ @ <form method="post">
464
+ @ <ul>
465
+ @ <li> Filename of the cache database: <b>%h(zDbName)</b>
466
+ @ <li> Size of the cache database: %s(zBuf)
467
+ @ <li> Maximum number of entries: %d(mxEntry);
468
+ @ <li> Number of slots used: %d(nEntry)
469
+ @ <li> Change the max-cache-entry setting on the
470
+ @ <a href="%R/setup_settings">Settings</a> page to adjust the
471
+ @ maximum number of entries in the cache.
472
+ @ <li><input type="submit" name="clear" value="Clear the cache">
473
+ @ <li> Disable the cache by manually deleting the cache database file.
474
+ @ </ul>
475
+ @ </form>
459476
fossil_free(zDbName);
460477
sqlite3_close(db);
461478
}
462479
style_finish_page();
463480
}
464481
--- src/cache.c
+++ src/cache.c
@@ -418,10 +418,15 @@
418 @ The web-page cache is disabled for this repository
419 @ <input type="submit" name="init" value="Enable">
420 @ </form>
421 }else{
422 char *zDbName = cacheName();
 
 
 
 
 
423 cache_register_sizename(db);
424 pStmt = cacheStmt(db,
425 "SELECT key, sz, nRef, datetime(tm,'unixepoch')"
426 " FROM cache"
427 " ORDER BY (tm + 3600*min(nRef,48)) DESC"
@@ -438,26 +443,38 @@
438 if( zHash ){
439 @ %z(href("%R/timeline?c=%S",zHash))check-in</a>\
440 fossil_free(zHash);
441 }
442 @ </p></li>
443
444 }
445 sqlite3_finalize(pStmt);
446 @ </ol>
447 }
448 zDbName = cacheName();
449 bigSizeName(sizeof(zBuf), zBuf, file_size(zDbName, ExtFILE));
450 @ <p>
451 @ cache-file name: %h(zDbName)<br>
452 @ cache-file size: %s(zBuf)<br>
453 @ max-cache-entry: %d(db_get_int("max-cache-entry",10))
454 @ </p>
455 @ <p>
456 @ Use the "<a href="%R/help?cmd=cache">fossil cache</a>" command
457 @ on the command-line to create and configure the web-cache.
458 @ </p>
 
 
 
 
 
 
 
 
 
 
 
 
459 fossil_free(zDbName);
460 sqlite3_close(db);
461 }
462 style_finish_page();
463 }
464
--- src/cache.c
+++ src/cache.c
@@ -418,10 +418,15 @@
418 @ The web-page cache is disabled for this repository
419 @ <input type="submit" name="init" value="Enable">
420 @ </form>
421 }else{
422 char *zDbName = cacheName();
423 int nEntry = 0;
424 int mxEntry = 0;
425 if( P("clearcache")!=0 && cgi_csrf_safe(2) ){
426 sqlite3_exec(db, "DELETE FROM cache; DELETE FROM blob; VACUUM;",0,0,0);
427 }
428 cache_register_sizename(db);
429 pStmt = cacheStmt(db,
430 "SELECT key, sz, nRef, datetime(tm,'unixepoch')"
431 " FROM cache"
432 " ORDER BY (tm + 3600*min(nRef,48)) DESC"
@@ -438,26 +443,38 @@
443 if( zHash ){
444 @ %z(href("%R/timeline?c=%S",zHash))check-in</a>\
445 fossil_free(zHash);
446 }
447 @ </p></li>
448 nEntry++;
449 }
450 sqlite3_finalize(pStmt);
451 @ </ol>
452 }
453 zDbName = cacheName();
454 bigSizeName(sizeof(zBuf), zBuf, file_size(zDbName, ExtFILE));
455 mxEntry = db_get_int("max-cache-entry",10);
456 @ <p>
457 @ </p>
458 @ <h2>About The Web-Cache</h2>
459 @ <p>
460 @ The web-cache is a separate database file that holds cached copies
461 @ tarballs, ZIP archives, and other pages that are expensive to compute
462 @ and are likely to be reused.
463 @ <form method="post">
464 @ <ul>
465 @ <li> Filename of the cache database: <b>%h(zDbName)</b>
466 @ <li> Size of the cache database: %s(zBuf)
467 @ <li> Maximum number of entries: %d(mxEntry);
468 @ <li> Number of slots used: %d(nEntry)
469 @ <li> Change the max-cache-entry setting on the
470 @ <a href="%R/setup_settings">Settings</a> page to adjust the
471 @ maximum number of entries in the cache.
472 @ <li><input type="submit" name="clear" value="Clear the cache">
473 @ <li> Disable the cache by manually deleting the cache database file.
474 @ </ul>
475 @ </form>
476 fossil_free(zDbName);
477 sqlite3_close(db);
478 }
479 style_finish_page();
480 }
481

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button