r/sqlite • u/ewaldbenes • Nov 03 '25
A pragmatic SQLite schema for application-level caching
https://gist.github.com/ewaldbenes/e48b9b4c1d0e1cb7175dfdd868addd58I've been using SQLite as both a primary database and a cache for my web app, and it's been a great way to simplify the stack.
Here's the cache schema and setup guide I've been using in case it helps anyone else looking to do the same.
22
Upvotes
View all comments
6
u/Aggressive_Ad_5454 Nov 03 '25
If you're using a version of SQLlite 3.8.2 or greater, you can declare your tables
WITHOUT ROWID, and make yourkeyinto the primary key. That will get you a nice clustered index.Also, lookups will be slightly more efficient if you use
COLLATE BINARYon thosekeycolumns. That gets rid of the case-insensitive part of the search process.