I'm asking this, because I don't know, if this is a correct way to do it:
I'm using two server applications in the same directory. Both non-ui-apps have to access the same files:
File 1:
The first file is an RandomAccessFile which I load in both applications with
and
write to it in both of the apps with
File 2:
The second file is a keyvaluestore 1-file (sqlite), which I set to wal-mode:
In both apps I initialize the kvs with
The first application reads and writes to this kvs, the second only has to remove sometimes a key with
The second file (kvs) seems to be access from both applications in a correct way. The first file (randomaccess) will sometimes be forged, when both apps are started.
I'm not sure, if I could do it in such a way. Even, if the first file will be written correctly, is it sure, that it will work with more traffic?
Perhaps, somebody has some experiences with such multi accessing. Thanks for each small advice...
I'm using two server applications in the same directory. Both non-ui-apps have to access the same files:
File 1:
The first file is an RandomAccessFile which I load in both applications with
B4X:
Public Kontakte As Map
...
If File.Exists(File.DirApp, "Kontakte.eis") Then
Dim Kontaktdatei As RandomAccessFile
Kontaktdatei.Initialize(File.DirApp,"Kontakte.eis", False)
Kontakte = Kontaktdatei.ReadB4XObject(0)
Kontaktdatei.Close
Else
Kontakte.Initialize
End If
and
write to it in both of the apps with
B4X:
Public Value As List
...
Kontakte.Put(key, Value)
Dim Kontaktdatei As RandomAccessFile
Kontaktdatei.Initialize(File.DirApp, "Kontakte.eis", False)
Kontaktdatei.WriteB4XObject(Kontakte, 0)
Kontaktdatei.Close
File 2:
The second file is a keyvaluestore 1-file (sqlite), which I set to wal-mode:
In both apps I initialize the kvs with
B4X:
Public NutzerDatenbank As KeyValueStore
...
NutzerDatenbank.Initialize(File.DirApp, "NutzerDatenbank")
The first application reads and writes to this kvs, the second only has to remove sometimes a key with
B4X:
Public Sub DeleteUser (name As String) As Boolean
Try
NutzerDatenbank.Remove(name)
Return True
Catch
Return False
End Try
End Sub
The second file (kvs) seems to be access from both applications in a correct way. The first file (randomaccess) will sometimes be forged, when both apps are started.
I'm not sure, if I could do it in such a way. Even, if the first file will be written correctly, is it sure, that it will work with more traffic?
Perhaps, somebody has some experiences with such multi accessing. Thanks for each small advice...