mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
configDB.pm: added FileRead caching (experimental)
git-svn-id: https://svn.fhem.de/fhem/trunk@7678 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
d18d80761c
commit
67efa8c39e
@ -99,6 +99,8 @@
|
||||
#
|
||||
# 2015-01-23 - changed attribute handling for internal configDB attrs
|
||||
#
|
||||
# 2015-01-23 - added FileRead() caching - experimental
|
||||
#
|
||||
##############################################################################
|
||||
#
|
||||
|
||||
@ -293,7 +295,7 @@ sub cfgDB_AttrRead($) {
|
||||
sub cfgDB_FileRead($) {
|
||||
my ($filename) = @_;
|
||||
|
||||
if ($configDB{cache}{$filename}) {
|
||||
if ($configDB{cache}{$filename} && $configDB{attr}{useCache}) {
|
||||
Log3(undef, 4, "configDB serving from cache: $filename");
|
||||
return (undef,split(/\n/,$configDB{cache}{$filename}));
|
||||
}
|
||||
@ -307,8 +309,10 @@ sub cfgDB_FileRead($) {
|
||||
$fhem_dbh->disconnect();
|
||||
$counter = length($blobContent);
|
||||
if($counter) {
|
||||
Log3(undef,4,"configDB caching: $filename");
|
||||
$configDB{cache}{$filename} = $blobContent;
|
||||
if ($configDB{attr}{useCache}) {
|
||||
Log3(undef,4,"configDB caching: $filename");
|
||||
$configDB{cache}{$filename} = $blobContent;
|
||||
}
|
||||
@ret = split(/\n/,$blobContent);
|
||||
$err = "";
|
||||
} else {
|
||||
@ -319,8 +323,10 @@ sub cfgDB_FileRead($) {
|
||||
}
|
||||
sub cfgDB_FileWrite($@) {
|
||||
my ($filename,@content) = @_;
|
||||
Log3(undef,4,"configDB delete from cache: $filename");
|
||||
$configDB{cache}{$filename} = undef;
|
||||
if ($configDB{attr}{useCache}) {
|
||||
Log3(undef,4,"configDB delete from cache: $filename");
|
||||
$configDB{cache}{$filename} = undef;
|
||||
}
|
||||
Log3(undef, 4, "configDB writing file: $filename");
|
||||
my $fhem_dbh = _cfgDB_Connect;
|
||||
$fhem_dbh->do("delete from fhembinfilesave where filename = '$filename'");
|
||||
|
Loading…
Reference in New Issue
Block a user