Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Improvements to the "fossil cache" command. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
e0ebe6f0338825affb13e19d3f9c2af9 |
User & Date: | drh 2021-06-16 01:10:41 |
Context
2021-06-16
| ||
03:12 | Show the exact size of each cache entry in the web cache status page. ... (check-in: 45e11fe4 user: drh tags: trunk) | |
01:10 | Improvements to the "fossil cache" command. ... (check-in: e0ebe6f0 user: drh tags: trunk) | |
2021-06-15
| ||
17:20 | Factored out an extraneous var from [1bb06c94]. No functional changes. ... (check-in: e0686dda user: stephan tags: trunk) | |
Changes
Changes to src/cache.c.
︙ | ︙ | |||
195 196 197 198 199 200 201 202 203 204 205 206 207 208 | cache_write_end: sqlite3_finalize(pStmt); sqlite3_exec(db, rc ? "COMMIT" : "ROLLBACK", 0, 0, 0); sqlite3_close(db); } /* ** Attempt to read content out of the cache with the given zKey. Return ** non-zero on success and zero if unable to locate the content. ** ** Possible reasons for returning zero: ** (1) This server does not implement a cache ** (2) The requested element is not in the cache | > > > > > > > | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | cache_write_end: sqlite3_finalize(pStmt); sqlite3_exec(db, rc ? "COMMIT" : "ROLLBACK", 0, 0, 0); sqlite3_close(db); } /* ** SETTING: max-cache-entry width=10 default=10 ** ** This is the maximum number of entries to allow in the web-cache ** for tarballs, ZIP-archives, and SQL-archives. */ /* ** Attempt to read content out of the cache with the given zKey. Return ** non-zero on success and zero if unable to locate the content. ** ** Possible reasons for returning zero: ** (1) This server does not implement a cache ** (2) The requested element is not in the cache |
︙ | ︙ | |||
260 261 262 263 264 265 266 267 268 269 270 271 272 273 | ** clear Remove all entries from the cache. ** ** init Create the cache file if it does not already exist. ** ** list|ls List the keys and content sizes and other stats for ** all entries currently in the cache. ** ** status Show a summary of the cache status. ** ** The cache is stored in a file that is distinct from the repository ** but that is held in the same directory as the repository. The cache ** file can be deleted in order to completely disable the cache. */ void cache_cmd(void){ | > > | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | ** clear Remove all entries from the cache. ** ** init Create the cache file if it does not already exist. ** ** list|ls List the keys and content sizes and other stats for ** all entries currently in the cache. ** ** size ?N? Query or set the maximum number of entries in the cache. ** ** status Show a summary of the cache status. ** ** The cache is stored in a file that is distinct from the repository ** but that is held in the same directory as the repository. The cache ** file can be deleted in order to completely disable the cache. */ void cache_cmd(void){ |
︙ | ︙ | |||
301 302 303 304 305 306 307 | if( db ){ sqlite3_exec(db, "DELETE FROM cache; DELETE FROM blob; VACUUM;",0,0,0); sqlite3_close(db); fossil_print("cache cleared\n"); }else{ fossil_print("nothing to clear; cache does not exist\n"); } | | | > > > | | | | | > | > > > > > > > | > | > > > > | | | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | if( db ){ sqlite3_exec(db, "DELETE FROM cache; DELETE FROM blob; VACUUM;",0,0,0); sqlite3_close(db); fossil_print("cache cleared\n"); }else{ fossil_print("nothing to clear; cache does not exist\n"); } }else if( strncmp(zCmd, "list", nCmd)==0 || strncmp(zCmd, "ls", nCmd)==0 || strncmp(zCmd, "status", nCmd)==0 ){ db = cacheOpen(0); if( db==0 ){ fossil_print("cache does not exist\n"); }else{ int nEntry = 0; char *zDbName = cacheName(); cache_register_sizename(db); pStmt = cacheStmt(db, "SELECT key, sizename(sz), nRef, datetime(tm,'unixepoch')" " FROM cache" " ORDER BY tm DESC" ); if( pStmt ){ while( sqlite3_step(pStmt)==SQLITE_ROW ){ if( zCmd[0]=='l' ){ fossil_print("%s %4d %8s %s\n", sqlite3_column_text(pStmt, 3), sqlite3_column_int(pStmt, 2), sqlite3_column_text(pStmt, 1), sqlite3_column_text(pStmt, 0)); } nEntry++; } sqlite3_finalize(pStmt); } sqlite3_close(db); fossil_print( "Filename: %s\n" "Entries: %d\n" "max-cache-entry: %d\n" "Cache-file Size: %,lld\n", zDbName, nEntry, db_get_int("max-cache-entry",10), file_size(zDbName, ExtFILE) ); fossil_free(zDbName); } }else if( strncmp(zCmd, "size", nCmd)==0 ){ if( g.argc>=4 ){ int n = atoi(g.argv[3]); if( n>=5 ) db_set_int("max-cache-entry",n,0); } fossil_print("max-cache-entry: %d\n", db_get_int("max-cache-entry",10)); }else{ fossil_fatal("Unknown subcommand \"%s\"." " Should be one of: clear init list size status", zCmd); } } /* ** WEBPAGE: cachestat ** ** Show information about the webpage cache. Requires Setup privilege. |
︙ | ︙ | |||
378 379 380 381 382 383 384 | @ last-access: %s(sqlite3_column_text(pStmt,3))</p></li> } sqlite3_finalize(pStmt); @ </ol> } zDbName = cacheName(); bigSizeName(sizeof(zBuf), zBuf, file_size(zDbName, ExtFILE)); | > | | > > > > > > | 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | @ last-access: %s(sqlite3_column_text(pStmt,3))</p></li> } sqlite3_finalize(pStmt); @ </ol> } zDbName = cacheName(); bigSizeName(sizeof(zBuf), zBuf, file_size(zDbName, ExtFILE)); @ <p> @ cache-file name: %h(zDbName)<br> @ cache-file size: %s(zBuf)<br> @ max-cache-entry: %d(db_get_int("max-cache-entry",10)) @ </p> @ <p> @ Use the "<a href="%R/help?cmd=cache">fossil cache</a>" command @ on the command-line to create and configure the web-cache. @ </p> fossil_free(zDbName); sqlite3_close(db); } style_finish_page(); } /* |
︙ | ︙ |