feat(perl-client): 新增 Perl 客户端 SDK 及 demo,各客户端版本统一为 1.0.3

This commit is contained in:
2026-07-07 21:11:04 +08:00
parent a70d378b91
commit 1f6da33371
15 changed files with 550 additions and 5 deletions
@@ -0,0 +1,33 @@
package Kenaito::Conf::Cache;
use strict;
use warnings;
use JSON::PP;
use File::Spec;
use constant CACHE_FILE => 'config-cache.json';
sub new {
my ($class, $cache_dir) = @_;
$cache_dir //= '.';
return bless { dir => $cache_dir }, $class;
}
sub write {
my ($self, $data) = @_;
my $path = File::Spec->catfile($self->{dir}, CACHE_FILE);
open my $fh, '>:encoding(UTF-8)', $path or return;
print $fh JSON::PP->new->utf8->encode($data);
close $fh;
}
sub read {
my ($self) = @_;
my $path = File::Spec->catfile($self->{dir}, CACHE_FILE);
open my $fh, '<:encoding(UTF-8)', $path or return undef;
local $/;
my $json = <$fh>;
close $fh;
return eval { JSON::PP->new->utf8->decode($json) };
}
1;