X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=libvideosite.pm;h=c39d9e5c79b8cd8bfdffadeb41810440c9f64028;hb=09d45a4c4460dce9322f4528dad5123322ab6b38;hp=3554201c814b7b05694bb2916960a326b4e94c2b;hpb=13d23a6f19e2f8192d894171aaecc7987044a72a;p=videosite.git diff --git a/libvideosite.pm b/libvideosite.pm index 3554201..c39d9e5 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; @@ -127,8 +127,8 @@ my $videosite_commands = { _cmd_nodebug(@_); }, - 'cache' => sub { - _cmd_cache(@_); + 'service' => sub { + _cmd_service(@_); }, }; @@ -931,14 +931,42 @@ sub _cmd_nodebug { } # -# Display the content of the config cache +# Handle generic service commands # -sub _cmd_cache { +sub _cmd_service { my $event = shift; + my $subcmd = shift || ''; - _io("Content of config cache:"); - foreach (sort(keys(%config_cache))) { - _io("%s => %s", $_, Dumper($config_cache{$_})); + $subcmd = lc($subcmd); + + if ($subcmd eq 'cache') { + _cmd_service_cache($event, @_); + } +} + + +# +# Display or clear the content of the config cache +# +sub _cmd_service_cache { + my $event = shift; + my $subcmd = shift; + + $subcmd = 'list' unless defined($subcmd); + $subcmd = lc($subcmd); + + if ($subcmd eq 'list') { + _io("Content of config cache:"); + foreach (sort(keys(%config_cache))) { + if (exists($config_cache{$_}->{value})) { + _io(" %s => %s", $_, $config_cache{$_}->{value}); + } else { + _io(" %s present", $_); + } + } + } elsif ($subcmd eq 'clear') { + %config_cache = (); + _io("Cache cleared"); } }