mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-18 15:03:06 +03:00
update connections
This commit is contained in:
@@ -30,11 +30,6 @@ namespace Emby.Server.Implementations.Data
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
protected virtual bool EnableConnectionPooling
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
static BaseSqliteRepository()
|
||||
{
|
||||
SQLite3.EnableSharedCache = false;
|
||||
@@ -45,7 +40,7 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
private static bool _versionLogged;
|
||||
|
||||
protected virtual SQLiteDatabaseConnection CreateConnection(bool isReadOnly = false)
|
||||
protected SQLiteDatabaseConnection CreateConnection(bool isReadOnly = false, Action<SQLiteDatabaseConnection> onConnect = null)
|
||||
{
|
||||
if (!_versionLogged)
|
||||
{
|
||||
@@ -56,7 +51,7 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
ConnectionFlags connectionFlags;
|
||||
|
||||
//isReadOnly = false;
|
||||
isReadOnly = false;
|
||||
|
||||
if (isReadOnly)
|
||||
{
|
||||
@@ -70,46 +65,40 @@ namespace Emby.Server.Implementations.Data
|
||||
connectionFlags |= ConnectionFlags.ReadWrite;
|
||||
}
|
||||
|
||||
if (EnableConnectionPooling)
|
||||
{
|
||||
connectionFlags |= ConnectionFlags.SharedCached;
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionFlags |= ConnectionFlags.PrivateCache;
|
||||
}
|
||||
|
||||
connectionFlags |= ConnectionFlags.SharedCached;
|
||||
connectionFlags |= ConnectionFlags.NoMutex;
|
||||
|
||||
var db = SQLite3.Open(DbFilePath, connectionFlags, null);
|
||||
|
||||
var queries = new List<string>
|
||||
{
|
||||
"pragma default_temp_store = memory",
|
||||
"pragma temp_store = memory",
|
||||
"PRAGMA page_size=4096",
|
||||
"PRAGMA journal_mode=WAL",
|
||||
"PRAGMA temp_store=memory",
|
||||
"PRAGMA synchronous=Normal",
|
||||
"pragma synchronous=Normal",
|
||||
//"PRAGMA cache size=-10000"
|
||||
};
|
||||
|
||||
var cacheSize = CacheSize;
|
||||
if (cacheSize.HasValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (EnableExclusiveMode)
|
||||
{
|
||||
queries.Add("PRAGMA locking_mode=EXCLUSIVE");
|
||||
}
|
||||
|
||||
//foreach (var query in queries)
|
||||
//var cacheSize = CacheSize;
|
||||
//if (cacheSize.HasValue)
|
||||
//{
|
||||
// db.Execute(query);
|
||||
|
||||
//}
|
||||
|
||||
db.ExecuteAll(string.Join(";", queries.ToArray()));
|
||||
////foreach (var query in queries)
|
||||
////{
|
||||
//// db.Execute(query);
|
||||
////}
|
||||
|
||||
using (WriteLock.Write())
|
||||
{
|
||||
db.ExecuteAll(string.Join(";", queries.ToArray()));
|
||||
|
||||
if (onConnect != null)
|
||||
{
|
||||
onConnect(db);
|
||||
}
|
||||
}
|
||||
|
||||
return db;
|
||||
}
|
||||
@@ -122,11 +111,6 @@ namespace Emby.Server.Implementations.Data
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool EnableExclusiveMode
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
internal static void CheckOk(int rc)
|
||||
{
|
||||
string msg = "";
|
||||
|
||||
Reference in New Issue
Block a user