Skip to content

Commit

Permalink
New Version 1.25.1
Browse files Browse the repository at this point in the history
  • Loading branch information
OllisGit committed Jan 31, 2021
1 parent 1df1bac commit d630580
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
57 changes: 57 additions & 0 deletions octoprint_DisplayLayerProgress/CachedSettings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# coding=utf-8
from __future__ import absolute_import


class CachedSettings():

cacheEnabled = True
cacheDict = {}

def __init__(self, pluginSettings):
self._pluginSettings = pluginSettings

def updateSettings(self, pluginSettings):
self._pluginSettings = pluginSettings
self.cacheDict = {}


def getStringValue(self, settingsKey):
value = self._getValueFromCache(settingsKey)
if (value == None):
# try to read from real settings
value = self._pluginSettings.get([settingsKey])
# add to cache if needed
if (value != None and self.cacheEnabled == True):
self.cacheDict[settingsKey] = value

return value

def getIntValue(self, settingsKey):
value = self._getValueFromCache(settingsKey)
if (value == None):
# try to read from real settings
value = self._pluginSettings.get_int([settingsKey])
# add to cache if needed
if (value != None and self.cacheEnabled == True):
self.cacheDict[settingsKey] = value

return value

def getBooleanValue(self, settingsKey):
value = self._getValueFromCache(settingsKey)
if (value == None):
# try to read from real settings
value = self._pluginSettings.get_boolean([settingsKey])
# add to cache if needed
if (value != None and self.cacheEnabled == True):
self.cacheDict[settingsKey] = value

return value

def _getValueFromCache(self, settingsKey):
value = None
if (self.cacheEnabled == True):
if (settingsKey in self.cacheDict):
value = self.cacheDict[settingsKey]
return value

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "DisplayLayerProgress"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "1.25.0"
plugin_version = "1.25.1"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit d630580

Please sign in to comment.