亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

In-Memory Databases

系統(tǒng) 1788 0

In-Memory Databases

In-Memory Databases

An SQLite database is normally stored in a single ordinary disk file. However, in certain circumstances, the database might be stored in memory.

The most common way to force an SQLite database to exist purely in memory is to open the database using the special filename " :memory: ". In other words, instead of passing the name of a real disk file into one of the sqlite3_open() , sqlite3_open16() , or sqlite3_open_v2() functions, pass in the string ":memory:". For example:

        rc = sqlite3_open(":memory:", &db);

      

When this is done, no disk file is opened. Instead, a new database is created purely in memory. The database ceases to exist as soon as the database connection is closed. Every :memory: database is distinct from every other. So, opening two database connections each with the filename ":memory:" will create two independent in-memory databases.

The special filename ":memory:" can be used anywhere that a database filename is permitted. For example, it can be used as the filename in an ATTACH command:

        ATTACH DATABASE ':memory:' AS aux1;

      

Note that in order for the special ":memory:" name to apply and to create a pure in-memory database, there must be no additional text in the filename. Thus, a disk-based database can be created in a file by prepending a pathname, like this: "./:memory:".

The special ":memory:" filename also works when using URI filenames . For example:

        rc = sqlite3_open("file::memory:", &db);

      
Or,
        ATTACH DATABASE 'file::memory:' AS aux1;

      

In-memory Databases And Shared Cache

In-memory databases are allowed to use shared cache if they are opened using a URI filename . If the unadorned ":memory:" name is used to specify the in-memory database, then that database always has a private cache and is this only visible to the database connection that originally opened it. However, the same in-memory database can be opened by two or more database connections as follows:

        rc = sqlite3_open("file::memory:?cache=shared", &db);

      
Or,
        ATTACH DATABASE 'file::memory:?cache=shared' AS aux1;

      

This allows separate database connections to share the same in-memory database. Of course, all database connections sharing the in-memory database need to be in the same process. The database is automatically deleted and memory is reclaimed when the last connection to the database closes.

If two or more distinct but shareable in-memory databases are needed in a single process, then the mode=memory query parameter can be used with a URI filename to create a named in-memory database:

        rc = sqlite3_open("file:memdb1?mode=memory&cache=shared", &db);

      
Or,
        ATTACH DATABASE 'file:memdb1?mode=memory&cache=shared' AS aux1;

      

When an in-memory database is named in this way, it will only share its cache with another connection that uses exactly the same name.

Temporary Databases

When the name of the database file handed to sqlite3_open() or to ATTACH is an empty string, then a new temporary file is created to hold the database.

        rc = sqlite3_open("", &db);

      
        ATTACH DATABASE '' AS aux2;

      

A different temporary file is created each time, so that just like as with the special ":memory:" string, two database connections to temporary databases each have their own private database. Temporary databases are automatically deleted when the connection that created them closes.

Even though a disk file is allocated for each temporary database, in practice the temporary database usually resides in the in-memory pager cache and hence is very little difference between a pure in-memory database created by ":memory:" and a temporary database created by an empty filename. The sole difference is that a ":memory:" database must remain in memory at all times whereas parts of a temporary database might be flushed to disk if database becomes large or if SQLite comes under memory pressure.

The previous paragraphs describe the behavior of temporary databases under the default SQLite configuration. An application can use the temp_store pragma and the SQLITE_TEMP_STORE compile-time parameter to force temporary databases to behave as pure in-memory databases, if desired.

In-Memory Databases


更多文章、技術交流、商務合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 国产高清美女一级a毛片久久 | 性视频一区二区三区免费 | 九九99久麻豆精品视传媒 | 国产一区二区在线视频 | 国产高清一区二区三区四区 | 中文字幕精品久久 | 欧美日韩福利视频一区二区三区 | 91在线视频免费看 | 国产亚洲精品色一区 | 欧美一区二区手机在线观看视频 | 99免费在线播放99久久免费 | 日韩久久久精品中文字幕 | 国产欧美综合在线一区二区三区 | 亚洲欧美精品国产一区色综合 | 中文字幕日韩在线一区国内 | 久久精品视频免费在线观看 | 快射影院| 亚洲精品不卡在线 | 99久久99久久久99精品齐 | 亚洲精品综合一区二区三区 | 狠狠综合欧美综合欧美色 | 亚洲精品综合久久 | 色综合天 | 免费黄色小视频在线观看 | 天天干天天做 | 四虎免费最新在线永久 | 一区二区三区四区五区 | 亚洲乱码一区二区三区国产精品 | 国产精品2020观看久久 | 高清在线亚洲精品国产二区 | 色的综合 | 欧美亚洲国产一区二区三区 | 爱爱免费视频网站 | 欧美成人一区二区三区 | 99久久99久久精品免费看子 | 老司机深夜影院入口aaaa | 日本一级毛片在线播放 | 日韩中文字幕在线有码视频网 | 日韩中文在线视频 | 老子影院午夜伦不卡不四虎卡 | 热e国产 |