B2G/gecko/storage/test/unit/test_cache_size.js
/**
 * In order to change the cache size, we must open a DB, change the page
 * size, create a table, close the DB, then re-open the DB.  We then check
 * the cache size after reopening.
 *
 * @param dbOpener
 *        function that opens the DB specified in file
 * @param file
 *        file holding the database
 * @param pageSize
 *        the DB's page size
 * @param expectedCacheSize
 *        the expected cache size for the given page size
 */
In order to change the cache size, we must open a DB, change the page
size, create a table, close the DB, then re-open the DB.  We then check
the cache size after reopening.

@param dbOpener
function that opens the DB specified in file
@param file
file holding the database
@param pageSize
the DB's page size
@param expectedCacheSize
the expected cache size for the given page size
In order to change the cache size we must open a DB change the page size create a table close the DB then re - open the DB . We then check the cache size after reopening . @param dbOpener function that opens the DB specified in file @param file file holding the database @param pageSize the DB ' s page size @param expectedCacheSize the expected cache size for the given page size
function check_size(dbOpener, file, pageSize, expectedCacheSize)
{
  let db = dbOpener(file);
  db.executeSimpleSQL("PRAGMA page_size = " + pageSize);
  let stmt = db.createStatement("PRAGMA page_size");
  do_check_true(stmt.executeStep());
  do_check_eq(stmt.row.page_size, pageSize);
  stmt.finalize();
  db.executeSimpleSQL("CREATE TABLE test ( id INTEGER PRIMARY KEY )");
  db.close();
  db = dbOpener(file);
  let stmt = db.createStatement("PRAGMA cache_size");
  do_check_true(stmt.executeStep());
  do_check_eq(stmt.row.cache_size, expectedCacheSize);
  stmt.finalize();
}
function check_size ( dbOpener , file , pageSize , expectedCacheSize ) { let db = dbOpener ( file ) ; db . executeSimpleSQL ( "PRAGMA page_size = " + pageSize ) ; let stmt = db . createStatement ( "PRAGMA page_size" ) ; do_check_true ( stmt . executeStep ( ) ) ; do_check_eq ( stmt . row . page_size , pageSize ) ; stmt . finalize ( ) ; db . executeSimpleSQL ( "CREATE TABLE test ( id INTEGER PRIMARY KEY )" ) ; db . close ( ) ; db = dbOpener ( file ) ; let stmt = db . createStatement ( "PRAGMA cache_size" ) ; do_check_true ( stmt . executeStep ( ) ) ; do_check_eq ( stmt . row . cache_size , expectedCacheSize ) ; stmt . finalize ( ) ; }
In order to change the cache size, we must open a DB, change the page
 size, create a table, close the DB, then re-open the DB.
In order to change the cache size we must open a DB change the page size create a table close the DB then re - open the DB .
// Open the DB, immediately change its page size. // Check the page size change worked. // Create a simple table. // Close and re-open the DB. // Check cache size is as expected.