mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-01-31 05:10:45 -06:00
Added a new setting in account dialog to control whehter we load the cache db into memory or read it from disk
This commit is contained in:
parent
2c75ea5005
commit
5712dd735b
@ -12,6 +12,7 @@ reverse_timelines = boolean(default=False)
|
||||
announce_stream_status = boolean(default=True)
|
||||
retweet_mode = string(default="ask")
|
||||
persist_size = integer(default=0)
|
||||
load_cache_in_memory=boolean(default=True)
|
||||
show_screen_names = boolean(default=False)
|
||||
buffer_order = list(default=list('home','mentions', 'dm', 'sent_dm', 'sent_tweets','favorites','followers','friends','blocks','muted','events'))
|
||||
|
||||
|
@ -151,6 +151,7 @@ class accountSettingsController(globalSettingsController):
|
||||
else:
|
||||
self.dialog.set_value("general", "retweet_mode", _(u"Retweet with comments"))
|
||||
self.dialog.set_value("general", "persist_size", str(self.config["general"]["persist_size"]))
|
||||
self.dialog.set_value("general", "load_cache_in_memory", self.config["general"]["load_cache_in_memory"])
|
||||
self.dialog.create_reporting()
|
||||
self.dialog.set_value("reporting", "speech_reporting", self.config["reporting"]["speech_reporting"])
|
||||
self.dialog.set_value("reporting", "braille_reporting", self.config["reporting"]["braille_reporting"])
|
||||
@ -193,6 +194,7 @@ class accountSettingsController(globalSettingsController):
|
||||
self.config["general"]["relative_times"] = self.dialog.get_value("general", "relative_time")
|
||||
self.config["general"]["show_screen_names"] = self.dialog.get_value("general", "show_screen_names")
|
||||
self.config["general"]["max_tweets_per_call"] = self.dialog.get_value("general", "itemsPerApiCall")
|
||||
self.config["general"]["load_cache_in_memory"] = self.dialog.get_value("general", "load_cache_in_memory")
|
||||
if self.config["general"]["persist_size"] != self.dialog.get_value("general", "persist_size"):
|
||||
if self.dialog.get_value("general", "persist_size") == '':
|
||||
self.config["general"]["persist_size"] =-1
|
||||
|
@ -82,12 +82,19 @@ class baseSession(object):
|
||||
if os.path.exists(dbname):
|
||||
os.remove(dbname)
|
||||
return
|
||||
try:
|
||||
self.db.commit()
|
||||
except:
|
||||
output.speak(_("An exception occurred while saving the {app} database. It will be deleted and rebuilt automatically. If this error persists, send the error log to the {app} developers.").format(app=application.name),True)
|
||||
log.exception("Exception while saving {}".format(dbname))
|
||||
os.remove(dbname)
|
||||
# Let's check if we need to create a new SqliteDict object or we just need to call to commit in self.db.
|
||||
if self.settings["general"]["load_cache_in_memory"]:
|
||||
db=sqlitedict.SqliteDict(dbname, 'c')
|
||||
for k in self.db.keys():
|
||||
db[k] = self.db[k]
|
||||
db.close()
|
||||
else:
|
||||
try:
|
||||
self.db.commit()
|
||||
except:
|
||||
output.speak(_("An exception occurred while saving the {app} database. It will be deleted and rebuilt automatically. If this error persists, send the error log to the {app} developers.").format(app=application.name),True)
|
||||
log.exception("Exception while saving {}".format(dbname))
|
||||
os.remove(dbname)
|
||||
|
||||
def load_persistent_data(self):
|
||||
"""Import data from a database file from user config."""
|
||||
@ -100,7 +107,16 @@ class baseSession(object):
|
||||
return
|
||||
# try to load the db file.
|
||||
try:
|
||||
self.db=sqlitedict.SqliteDict(os.path.join(paths.config_path(), dbname), 'c')
|
||||
db=sqlitedict.SqliteDict(os.path.join(paths.config_path(), dbname), 'c')
|
||||
# If load_cache_in_memory is set to true, we will load the whole database into memory for faster access.
|
||||
# This is going to be faster when retrieving specific objects, at the cost of more memory.
|
||||
# Setting this to False will read the objects from database as they are needed, which might be slower for bigger datasets.
|
||||
if self.settings["general"]["load_cache_in_memory"]:
|
||||
for k in db.keys():
|
||||
self.db[k] = db[k]
|
||||
db.close()
|
||||
else:
|
||||
self.db = db
|
||||
if self.db.get("cursors") == None:
|
||||
cursors = dict(direct_messages=-1)
|
||||
self.db["cursors"] = cursors
|
||||
|
@ -1,7 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from builtins import range
|
||||
import logging as original_logger
|
||||
import wx
|
||||
import application
|
||||
@ -127,6 +124,7 @@ class generalAccount(wx.Panel, baseDialog.BaseWXDialog):
|
||||
self.persist_size = wx.TextCtrl(self, -1)
|
||||
sizer.Add(PersistSizeLabel, 0, wx.ALL, 5)
|
||||
sizer.Add(self.persist_size, 0, wx.ALL, 5)
|
||||
self.load_cache_in_memory = wx.CheckBox(self, wx.NewId(), _("Load cache for tweets in memory (much faster in big datasets but requires more RAM)"))
|
||||
self.SetSizer(sizer)
|
||||
|
||||
class reporting(wx.Panel, baseDialog.BaseWXDialog):
|
||||
|
Loading…
x
Reference in New Issue
Block a user