I am writing a small registration web server using abmaterial. I store users' info on a single json file.
I think it is too simple to use json as my database, so I sought to keyValueStore. SQLite+keyvalue sounds great. But my app just increases from 6mb to 12mb and costs running memory. Also, the code is not as easy to maintain as a json file.
The keyValueStore is like an in-memory NoSQL datebase based on SQLite. As I am not a professional, I'd rather to store on disk directly.
So I decide to roll my code back. Using Json to store data is fine right now. Maybe I should store users' info on separate files based on user's id, which can improve concurrent access.
I find out the reason. I used too many putasync methods where I should simply use put. These async methods make my system not responsive and I cannot see the result instantly.
thanks, I have added these code to set the wal pragma when creating the db file.
B4X:
'Initializes the store and sets the store file.
Public Sub Initialize (Dir As String, FileName As String)
If sql1.IsInitialized Then sql1.Close
#if B4J
If File.Exists(Dir,FileName) Then
sql1.InitializeSQLite(Dir, FileName, True)
Else
sql1.InitializeSQLite(Dir, FileName, True)
sql1.ExecNonQuery("PRAGMA journal_mode = wal")
End If
#else
sql1.Initialize(Dir, FileName, True)
#end if
CreateTable
End Sub