Function cached

Caches all the results of a query into memory at once.

CachedResults cached (
  ResultRange results
);

This allows to keep all the rows returned from a query accessible in any order and indefinitely.

Returns

A CachedResults struct that allows to iterate on the rows and their columns with an array-like interface.

The CachedResults struct is equivalent to an array of 'rows', which in turn can be viewed as either an array of ColumnData or as an associative array of ColumnData indexed by the column names.

Example

auto db = Database(":memory:");
db.run("CREATE TABLE test (msg TEXT, num FLOAT);
        INSERT INTO test (msg, num) VALUES ('ABC', 123);
        INSERT INTO test (msg, num) VALUES ('DEF', 456);");

auto results = db.execute("SELECT * FROM test").cached;
assert(results.length == 2);
assert(results[0][0].as!string == "ABC");
assert(results[0][1].as!int == 123);
assert(results[1]["msg"].as!string == "DEF");
assert(results[1]["num"].as!int == 456);