X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=libvideosite.pm;h=bf02068a3e104a595732ce367b6caa15f8db4bb7;hb=f44eaa8476039480a3ee597fc1886b1a7fac7e10;hp=3f05160b27d29f52d5463b540ace51f8c7f4ffd5;hpb=63d28aaac2943e7527a33510949d2857473ab787;p=videosite.git diff --git a/libvideosite.pm b/libvideosite.pm index 3f05160..bf02068 100644 --- a/libvideosite.pm +++ b/libvideosite.pm @@ -34,7 +34,7 @@ my $getter; my %builtin_config = (); my $builtin_config_path; my $builtin_config_default; -my $config_cache = 0; +my $config_cache = 1; my %config_cache = (); our $error; @@ -52,7 +52,12 @@ my $defaultconfig = { 'name' => 'direct', '_immutable' => '1', 'schemas' => {}, - } + }, + 'environment' => { + 'name' => 'environment', + '_immutable' => '1', + 'schemas' => {}, + }, }, 'config-version' => '2', }; @@ -86,7 +91,7 @@ my $videosite_commands = { 'set' => sub { _cmd_set(@_); }, - + 'show' => sub { _cmd_show(@_); }, @@ -127,8 +132,8 @@ my $videosite_commands = { _cmd_nodebug(@_); }, - 'cache' => sub { - _cmd_cache(@_); + 'service' => sub { + _cmd_service(@_); }, }; @@ -279,7 +284,7 @@ sub _ploader { } _debug("Loaded %d plugins", $#g+1); - + return @g; } @@ -385,7 +390,7 @@ sub _config_list_add { _config_set($path, join(',', @c)); } -# +# # Remove an item from the list # sub _config_list_del { @@ -931,9 +936,24 @@ sub _cmd_nodebug { } # +# Handle generic service commands +# +sub _cmd_service { + my $event = shift; + my $subcmd = shift || ''; + + $subcmd = lc($subcmd); + + if ($subcmd eq 'cache') { + _cmd_service_cache($event, @_); + } +} + + +# # Display or clear the content of the config cache # -sub _cmd_cache { +sub _cmd_service_cache { my $event = shift; my $subcmd = shift; @@ -944,14 +964,14 @@ sub _cmd_cache { _io("Content of config cache:"); foreach (sort(keys(%config_cache))) { if (exists($config_cache{$_}->{value})) { - _io("%s => %s", $_, $config_cache{$_}->{value}); + _io(" %s => %s", $_, $config_cache{$_}->{value}); } else { - _io("%s present", $_); + _io(" %s present", $_); } } } elsif ($subcmd eq 'clear') { - _debug("Clearing config cache"); %config_cache = (); + _io("Cache cleared"); } }