Fossil SCM

Add a web-page for viewing the status of the web cache. Accessible as a submenu off of the stat page.

drh 2014-04-25 21:56 trunk
Commit 05477b2e06740cce6e5f6476accb8a509d01719a
2 files changed +46 +2 -1
+46
--- src/cache.c
+++ src/cache.c
@@ -316,5 +316,51 @@
316316
}else{
317317
fossil_fatal("Unknown subcommand \"%s\"."
318318
" Should be one of: clear init list status", zCmd);
319319
}
320320
}
321
+
322
+/*
323
+** WEBPAGE: cachestat
324
+**
325
+** Show information about the webpage cache
326
+*/
327
+void cache_page(void){
328
+ sqlite3 *db;
329
+ sqlite3_stmt *pStmt;
330
+ char *zDbName;
331
+ char zBuf[100];
332
+
333
+ login_check_credentials();
334
+ if( !g.perm.Setup ){ login_needed(); return; }
335
+ style_header("Web Cache Status");
336
+ db = cacheOpen(0);
337
+ if( db==0 ){
338
+ @ The web-page cache is disabled for this repository
339
+ }else{
340
+ char *zDbName = cacheName();
341
+ cache_register_sizename(db);
342
+ pStmt = cacheStmt(db,
343
+ "SELECT key, sizename(sz), nRef, datetime(tm,'unixepoch')"
344
+ " FROM cache"
345
+ " ORDER BY tm DESC"
346
+ );
347
+ if( pStmt ){
348
+ @ <ol>
349
+ while( sqlite3_step(pStmt)==SQLITE_ROW ){
350
+ @ <li><p>%h(sqlite3_column_text(pStmt,0))<br>
351
+ @ size: %s(sqlite3_column_text(pStmt,1))
352
+ @ hit-count: %d(sqlite3_column_int(pStmt,2))
353
+ @ last-access: %s(sqlite3_column_text(pStmt,3))</p></li>
354
+ }
355
+ sqlite3_finalize(pStmt);
356
+ @ </ol>
357
+ }
358
+ zDbName = cacheName();
359
+ bigSizeName(sizeof(zBuf), zBuf, file_size(zDbName));
360
+ @ <p>cache-file name: %h(zDbName)</p>
361
+ @ <p>cache-file size: %s(zBuf)</p>
362
+ fossil_free(zDbName);
363
+ sqlite3_close(db);
364
+ }
365
+ style_footer();
366
+}
321367
--- src/cache.c
+++ src/cache.c
@@ -316,5 +316,51 @@
316 }else{
317 fossil_fatal("Unknown subcommand \"%s\"."
318 " Should be one of: clear init list status", zCmd);
319 }
320 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
--- src/cache.c
+++ src/cache.c
@@ -316,5 +316,51 @@
316 }else{
317 fossil_fatal("Unknown subcommand \"%s\"."
318 " Should be one of: clear init list status", zCmd);
319 }
320 }
321
322 /*
323 ** WEBPAGE: cachestat
324 **
325 ** Show information about the webpage cache
326 */
327 void cache_page(void){
328 sqlite3 *db;
329 sqlite3_stmt *pStmt;
330 char *zDbName;
331 char zBuf[100];
332
333 login_check_credentials();
334 if( !g.perm.Setup ){ login_needed(); return; }
335 style_header("Web Cache Status");
336 db = cacheOpen(0);
337 if( db==0 ){
338 @ The web-page cache is disabled for this repository
339 }else{
340 char *zDbName = cacheName();
341 cache_register_sizename(db);
342 pStmt = cacheStmt(db,
343 "SELECT key, sizename(sz), nRef, datetime(tm,'unixepoch')"
344 " FROM cache"
345 " ORDER BY tm DESC"
346 );
347 if( pStmt ){
348 @ <ol>
349 while( sqlite3_step(pStmt)==SQLITE_ROW ){
350 @ <li><p>%h(sqlite3_column_text(pStmt,0))<br>
351 @ size: %s(sqlite3_column_text(pStmt,1))
352 @ hit-count: %d(sqlite3_column_int(pStmt,2))
353 @ last-access: %s(sqlite3_column_text(pStmt,3))</p></li>
354 }
355 sqlite3_finalize(pStmt);
356 @ </ol>
357 }
358 zDbName = cacheName();
359 bigSizeName(sizeof(zBuf), zBuf, file_size(zDbName));
360 @ <p>cache-file name: %h(zDbName)</p>
361 @ <p>cache-file size: %s(zBuf)</p>
362 fossil_free(zDbName);
363 sqlite3_close(db);
364 }
365 style_footer();
366 }
367
+2 -1
--- src/stat.c
+++ src/stat.c
@@ -25,11 +25,11 @@
2525
2626
/*
2727
** For a sufficiently large integer, provide an alternative
2828
** representation as MB or GB or TB.
2929
*/
30
-static void bigSizeName(int nOut, char *zOut, sqlite3_int64 v){
30
+void bigSizeName(int nOut, char *zOut, sqlite3_int64 v){
3131
if( v<100000 ){
3232
sqlite3_snprintf(nOut, zOut, "%lld bytes", v);
3333
}else if( v<1000000000 ){
3434
sqlite3_snprintf(nOut, zOut, "%lld bytes (%.1fMB)",
3535
v, (double)v/1000000.0);
@@ -57,10 +57,11 @@
5757
brief = P("brief")!=0;
5858
style_header("Repository Statistics");
5959
if( g.perm.Admin ){
6060
style_submenu_element("URLs", "URLs and Checkouts", "urllist");
6161
style_submenu_element("Schema", "Repository Schema", "repo_schema");
62
+ style_submenu_element("Web-Cache", "Web-Cache Stats", "cachestat");
6263
}
6364
@ <table class="label-value">
6465
@ <tr><th>Repository&nbsp;Size:</th><td>
6566
fsize = file_size(g.zRepositoryName);
6667
bigSizeName(sizeof(zBuf), zBuf, fsize);
6768
--- src/stat.c
+++ src/stat.c
@@ -25,11 +25,11 @@
25
26 /*
27 ** For a sufficiently large integer, provide an alternative
28 ** representation as MB or GB or TB.
29 */
30 static void bigSizeName(int nOut, char *zOut, sqlite3_int64 v){
31 if( v<100000 ){
32 sqlite3_snprintf(nOut, zOut, "%lld bytes", v);
33 }else if( v<1000000000 ){
34 sqlite3_snprintf(nOut, zOut, "%lld bytes (%.1fMB)",
35 v, (double)v/1000000.0);
@@ -57,10 +57,11 @@
57 brief = P("brief")!=0;
58 style_header("Repository Statistics");
59 if( g.perm.Admin ){
60 style_submenu_element("URLs", "URLs and Checkouts", "urllist");
61 style_submenu_element("Schema", "Repository Schema", "repo_schema");
 
62 }
63 @ <table class="label-value">
64 @ <tr><th>Repository&nbsp;Size:</th><td>
65 fsize = file_size(g.zRepositoryName);
66 bigSizeName(sizeof(zBuf), zBuf, fsize);
67
--- src/stat.c
+++ src/stat.c
@@ -25,11 +25,11 @@
25
26 /*
27 ** For a sufficiently large integer, provide an alternative
28 ** representation as MB or GB or TB.
29 */
30 void bigSizeName(int nOut, char *zOut, sqlite3_int64 v){
31 if( v<100000 ){
32 sqlite3_snprintf(nOut, zOut, "%lld bytes", v);
33 }else if( v<1000000000 ){
34 sqlite3_snprintf(nOut, zOut, "%lld bytes (%.1fMB)",
35 v, (double)v/1000000.0);
@@ -57,10 +57,11 @@
57 brief = P("brief")!=0;
58 style_header("Repository Statistics");
59 if( g.perm.Admin ){
60 style_submenu_element("URLs", "URLs and Checkouts", "urllist");
61 style_submenu_element("Schema", "Repository Schema", "repo_schema");
62 style_submenu_element("Web-Cache", "Web-Cache Stats", "cachestat");
63 }
64 @ <table class="label-value">
65 @ <tr><th>Repository&nbsp;Size:</th><td>
66 fsize = file_size(g.zRepositoryName);
67 bigSizeName(sizeof(zBuf), zBuf, fsize);
68

Keyboard Shortcuts

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