From bb097294e2e47b4b49f8cbbabf8e290919de9b46 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Sat, 17 Mar 2018 13:48:23 +0100 Subject: [PATCH] Built-in image cache system --- CHANGELOG | 1 + cpanfile | 2 + cpanfile.snapshot | 309 +++++++++++++++++++++++- lib/Lutim.pm | 11 + lib/Lutim/Plugin/Helpers.pm | 36 ++- lib/Mounter.pm | 1 + lutim.conf.template | 9 +- t/postgresql1.conf | 11 + t/postgresql2.conf | 11 + t/postgresql3.conf | 11 + t/sqlite1.conf | 11 + t/sqlite2.conf | 11 + t/sqlite3.conf | 11 + t/test.t | 27 ++- themes/default/lib/Lutim/I18N/lutim.pot | 8 +- 15 files changed, 446 insertions(+), 24 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4fd8a5a..9cfb0b3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ Revision history for Lutim ????? ?????????? - PostgreSQL performance improvments - Move some tasks to recurring instead of being in after_dispatch hook + - Built-in image cache system \o/ 0.9.6 2018-03-12 - Update translations diff --git a/cpanfile b/cpanfile index 12b1cd9..b02cd39 100644 --- a/cpanfile +++ b/cpanfile @@ -27,3 +27,5 @@ requires 'Image::ExifTool'; requires 'Data::Entropy'; requires 'List::MoreUtils', '> 0.33'; requires 'Archive::Zip'; +requires 'CHI'; +requires 'Data::Serializer'; diff --git a/cpanfile.snapshot b/cpanfile.snapshot index 52123ab..5fc2f20 100644 --- a/cpanfile.snapshot +++ b/cpanfile.snapshot @@ -44,12 +44,65 @@ DISTRIBUTIONS perl 5.008001 strict 0 warnings 0 + CHI-0.60 + pathname: J/JS/JSWARTZ/CHI-0.60.tar.gz + provides: + CHI 0.60 + CHI::CacheObject 0.60 + CHI::Driver 0.60 + CHI::Driver::Base::CacheContainer 0.60 + CHI::Driver::CacheCache 0.60 + CHI::Driver::FastMmap 0.60 + CHI::Driver::File 0.60 + CHI::Driver::Memory 0.60 + CHI::Driver::Metacache 0.60 + CHI::Driver::Null 0.60 + CHI::Driver::RawMemory 0.60 + CHI::Driver::Role::HasSubcaches 0.60 + CHI::Driver::Role::IsSizeAware 0.60 + CHI::Driver::Role::IsSubcache 0.60 + CHI::Stats 0.60 + requirements: + Carp::Assert 0.20 + Class::Load 0 + Data::UUID 0 + Digest::JHash 0 + Digest::MD5 0 + ExtUtils::MakeMaker 0 + File::Spec 0.80 + Hash::MoreUtils 0 + JSON::MaybeXS 1.003003 + List::MoreUtils 0.13 + Log::Any 0.08 + Moo 1.003 + MooX::Types::MooseLike 0.23 + MooX::Types::MooseLike::Base 0 + MooX::Types::MooseLike::Numeric 0 + Storable 0 + String::RewritePrefix 0 + Task::Weaken 0 + Time::Duration 1.06 + Time::Duration::Parse 0.03 + Time::HiRes 1.30 + Try::Tiny 0.05 Canary-Stability-2012 pathname: M/ML/MLEHMANN/Canary-Stability-2012.tar.gz provides: Canary::Stability 2012 requirements: ExtUtils::MakeMaker 0 + Carp-Assert-0.21 + pathname: N/NE/NEILB/Carp-Assert-0.21.tar.gz + provides: + Carp::Assert 0.21 + requirements: + Carp 0 + Exporter 0 + ExtUtils::MakeMaker 0 + perl 5.006 + strict 0 + vars 0 + warnings 0 Class-Data-Inheritable-0.08 pathname: T/TM/TMTM/Class-Data-Inheritable-0.08.tar.gz provides: @@ -65,6 +118,25 @@ DISTRIBUTIONS ExtUtils::MakeMaker 0 File::Spec 0.80 perl 5.006 + Class-Load-0.24 + pathname: E/ET/ETHER/Class-Load-0.24.tar.gz + provides: + Class::Load 0.24 + Class::Load::PP 0.24 + requirements: + Carp 0 + Data::OptList 0 + Exporter 0 + ExtUtils::MakeMaker 0 + Module::Implementation 0.04 + Module::Runtime 0.012 + Package::Stash 0.14 + Scalar::Util 0 + Try::Tiny 0 + base 0 + perl 5.006 + strict 0 + warnings 0 Class-Method-Modifiers-2.12 pathname: E/ET/ETHER/Class-Method-Modifiers-2.12.tar.gz provides: @@ -287,6 +359,55 @@ DISTRIBUTIONS perl 5.006 strict 0 warnings 0 + Data-OptList-0.110 + pathname: R/RJ/RJBS/Data-OptList-0.110.tar.gz + provides: + Data::OptList 0.110 + requirements: + ExtUtils::MakeMaker 0 + List::Util 0 + Params::Util 0 + Sub::Install 0.921 + strict 0 + warnings 0 + Data-Serializer-0.60 + pathname: N/NE/NEELY/Data-Serializer-0.60.tar.gz + provides: + Data::Serializer 0.60 + Data::Serializer::Bencode 0.03 + Data::Serializer::Config::General 0.02 + Data::Serializer::Convert::Bencode 0.03 + Data::Serializer::Convert::Bencode_XS 0.03 + Data::Serializer::Cookbook 0.05 + Data::Serializer::Data::Denter 0.02 + Data::Serializer::Data::Dumper 0.05 + Data::Serializer::Data::Taxi 0.02 + Data::Serializer::FreezeThaw 0.02 + Data::Serializer::JSON 0.04 + Data::Serializer::JSON::Syck 0.02 + Data::Serializer::PHP::Serialization 0.02 + Data::Serializer::Persistent 0.01 + Data::Serializer::Raw 0.02 + Data::Serializer::Storable 0.03 + Data::Serializer::XML::Dumper 0.02 + Data::Serializer::XML::Simple 0.03 + Data::Serializer::YAML 0.02 + Data::Serializer::YAML::Syck 0.02 + requirements: + AutoLoader 0 + Data::Dumper 2.08 + Digest::SHA 0 + Exporter 0 + File::Spec 0 + IO::File 0 + Test::More 0 + Data-UUID-1.221 + pathname: R/RJ/RJBS/Data-UUID-1.221.tar.gz + provides: + Data::UUID 1.221 + requirements: + Digest::MD5 0 + ExtUtils::MakeMaker 0 Data-Validate-Domain-0.14 pathname: D/DR/DROLSKY/Data-Validate-Domain-0.14.tar.gz provides: @@ -797,6 +918,18 @@ DISTRIBUTIONS perl 5.006 strict 0 warnings 0 + Digest-JHash-0.10 + pathname: S/SH/SHLOMIF/Digest-JHash-0.10.tar.gz + provides: + Digest::JHash 0.10 + requirements: + DynaLoader 0 + Exporter 0 + ExtUtils::MakeMaker 0 + perl 5.008 + strict 0 + vars 0 + warnings 0 Dist-CheckConflicts-0.11 pathname: D/DO/DOY/Dist-CheckConflicts-0.11.tar.gz provides: @@ -846,6 +979,16 @@ DISTRIBUTIONS perl 5.008001 strict 0 warnings 0 + Exporter-Lite-0.08 + pathname: N/NE/NEILB/Exporter-Lite-0.08.tar.gz + provides: + Exporter::Lite 0.08 + requirements: + Carp 0 + ExtUtils::MakeMaker 6.3 + perl 5.006 + strict 0 + warnings 0 Exporter-Tiny-1.000000 pathname: T/TO/TOBYINK/Exporter-Tiny-1.000000.tar.gz provides: @@ -992,15 +1135,21 @@ DISTRIBUTIONS perl 5.005 strict 0 warnings 0 - Hash-Merge-0.299 - pathname: H/HE/HERMES/Hash-Merge-0.299.tar.gz + Hash-Merge-0.300 + pathname: R/RE/REHSACK/Hash-Merge-0.300.tar.gz provides: - Hash::Merge 0.299 + Hash::Merge 0.300 requirements: Clone::Choose 0.008 - ExtUtils::MakeMaker 0 + ExtUtils::MakeMaker 6.64 Scalar::Util 0 perl 5.008001 + Hash-MoreUtils-0.05 + pathname: R/RE/REHSACK/Hash-MoreUtils-0.05.tar.gz + provides: + Hash::MoreUtils 0.05 + requirements: + Test::More 0.90 IO-Socket-SSL-2.056 pathname: S/SU/SULLR/IO-Socket-SSL-2.056.tar.gz provides: @@ -1215,6 +1364,16 @@ DISTRIBUTIONS requirements: ExtUtils::MakeMaker 0 perl 5.004 + JSON-MaybeXS-1.003010 + pathname: H/HA/HAARG/JSON-MaybeXS-1.003010.tar.gz + provides: + JSON::MaybeXS 1.003010 + requirements: + Carp 0 + ExtUtils::MakeMaker 0 + JSON::PP 2.27300 + Scalar::Util 0 + perl 5.006 List-MoreUtils-0.428 pathname: R/RE/REHSACK/List-MoreUtils-0.428.tar.gz provides: @@ -1266,6 +1425,40 @@ DISTRIBUTIONS requirements: ExtUtils::MakeMaker 6.30 Locale::Maketext 1.17 + Log-Any-1.705 + pathname: P/PR/PREACTION/Log-Any-1.705.tar.gz + provides: + Log::Any 1.705 + Log::Any::Adapter 1.705 + Log::Any::Adapter::Base 1.705 + Log::Any::Adapter::File 1.705 + Log::Any::Adapter::Null 1.705 + Log::Any::Adapter::Stderr 1.705 + Log::Any::Adapter::Stdout 1.705 + Log::Any::Adapter::Syslog 1.705 + Log::Any::Adapter::Test 1.705 + Log::Any::Adapter::Util 1.705 + Log::Any::Manager 1.705 + Log::Any::Proxy 1.705 + Log::Any::Proxy::Null 1.705 + Log::Any::Proxy::Test 1.705 + Log::Any::Test 1.705 + requirements: + B 0 + Carp 0 + Data::Dumper 0 + Exporter 0 + ExtUtils::MakeMaker 0 + Fcntl 0 + File::Basename 0 + FindBin 0 + IO::File 0 + Storable 0 + Sys::Syslog 0 + Test::Builder 0 + constant 0 + strict 0 + warnings 0 MRO-Compat-0.13 pathname: H/HA/HAARG/MRO-Compat-0.13.tar.gz provides: @@ -1436,8 +1629,8 @@ DISTRIBUTIONS URI::db 0.15 URI::file 4.21 perl 5.010001 - Mojolicious-7.70 - pathname: S/SR/SRI/Mojolicious-7.70.tar.gz + Mojolicious-7.71 + pathname: S/SR/SRI/Mojolicious-7.71.tar.gz provides: Mojo undef Mojo::Asset undef @@ -1506,7 +1699,7 @@ DISTRIBUTIONS Mojo::UserAgent::Transactor undef Mojo::Util undef Mojo::WebSocket undef - Mojolicious 7.70 + Mojolicious 7.71 Mojolicious::Command undef Mojolicious::Command::cgi undef Mojolicious::Command::cpanify undef @@ -1619,6 +1812,24 @@ DISTRIBUTIONS Sub::Defer 2.003001 Sub::Quote 2.003001 perl 5.006 + MooX-Types-MooseLike-0.29 + pathname: M/MA/MATEU/MooX-Types-MooseLike-0.29.tar.gz + provides: + MooX::Types::MooseLike 0.29 + MooX::Types::MooseLike::Base 0.29 + requirements: + ExtUtils::MakeMaker 0 + Module::Runtime 0.014 + MooX-Types-MooseLike-Numeric-1.03 + pathname: M/MA/MATEU/MooX-Types-MooseLike-Numeric-1.03.tar.gz + provides: + MooX::Types::MooseLike::Numeric 1.03 + requirements: + ExtUtils::MakeMaker 0 + Moo 1.004002 + MooX::Types::MooseLike 0.23 + Test::Fatal 0.003 + Test::More 0.96 Mozilla-CA-20180117 pathname: A/AB/ABH/Mozilla-CA-20180117.tar.gz provides: @@ -1635,10 +1846,10 @@ DISTRIBUTIONS Carp 0 ExtUtils::MakeMaker 0 Storable 0 - Net-SSLeay-1.84 - pathname: M/MI/MIKEM/Net-SSLeay-1.84.tar.gz + Net-SSLeay-1.85 + pathname: M/MI/MIKEM/Net-SSLeay-1.85.tar.gz provides: - Net::SSLeay 1.84 + Net::SSLeay 1.85 Net::SSLeay::Handle 0.61 requirements: ExtUtils::MakeMaker 6.36 @@ -1701,6 +1912,17 @@ DISTRIBUTIONS perl 5.006001 strict 0 warnings 0 + Params-Util-1.07 + pathname: A/AD/ADAMK/Params-Util-1.07.tar.gz + provides: + Params::Util 1.07 + requirements: + ExtUtils::CBuilder 0.27 + ExtUtils::MakeMaker 6.52 + File::Spec 0.80 + Scalar::Util 1.18 + Test::More 0.42 + perl 5.00503 Params-ValidationCompiler-0.27 pathname: D/DR/DROLSKY/Params-ValidationCompiler-0.27.tar.gz provides: @@ -1824,6 +2046,29 @@ DISTRIBUTIONS strict 0 version 0.83 warnings 0 + String-RewritePrefix-0.007 + pathname: R/RJ/RJBS/String-RewritePrefix-0.007.tar.gz + provides: + String::RewritePrefix 0.007 + requirements: + Carp 0 + ExtUtils::MakeMaker 6.30 + Sub::Exporter 0.972 + strict 0 + warnings 0 + Sub-Exporter-0.987 + pathname: R/RJ/RJBS/Sub-Exporter-0.987.tar.gz + provides: + Sub::Exporter 0.987 + Sub::Exporter::Util 0.987 + requirements: + Carp 0 + Data::OptList 0.100 + ExtUtils::MakeMaker 6.30 + Params::Util 0.14 + Sub::Install 0.92 + strict 0 + warnings 0 Sub-Exporter-Progressive-0.001013 pathname: F/FR/FREW/Sub-Exporter-Progressive-0.001013.tar.gz provides: @@ -1837,6 +2082,17 @@ DISTRIBUTIONS requirements: ExtUtils::MakeMaker 0 Test::More 0 + Sub-Install-0.928 + pathname: R/RJ/RJBS/Sub-Install-0.928.tar.gz + provides: + Sub::Install 0.928 + requirements: + B 0 + Carp 0 + ExtUtils::MakeMaker 6.30 + Scalar::Util 0 + strict 0 + warnings 0 Sub-Quote-2.005000 pathname: H/HA/HAARG/Sub-Quote-2.005000.tar.gz provides: @@ -1867,6 +2123,17 @@ DISTRIBUTIONS Text::Balanced 2 if 0 perl 5.005 + Task-Weaken-1.05 + pathname: E/ET/ETHER/Task-Weaken-1.05.tar.gz + provides: + Task::Weaken 1.05 + requirements: + Config 0 + ExtUtils::MakeMaker 0 + File::Spec 0 + Scalar::Util 1.14 + perl 5.006 + strict 0 Test-Fatal-0.014 pathname: R/RJ/RJBS/Test-Fatal-0.014.tar.gz provides: @@ -1898,6 +2165,28 @@ DISTRIBUTIONS requirements: ExtUtils::MakeMaker 0 perl 5.008 + Time-Duration-1.20 + pathname: N/NE/NEILB/Time-Duration-1.20.tar.gz + provides: + Time::Duration 1.20 + requirements: + Exporter 0 + ExtUtils::MakeMaker 0 + constant 0 + perl 5.006 + strict 0 + warnings 0 + Time-Duration-Parse-0.13 + pathname: N/NE/NEILB/Time-Duration-Parse-0.13.tar.gz + provides: + Time::Duration::Parse 0.13 + requirements: + Carp 0 + Exporter::Lite 0 + ExtUtils::MakeMaker 0 + perl 5.006 + strict 0 + warnings 0 Try-Tiny-0.30 pathname: E/ET/ETHER/Try-Tiny-0.30.tar.gz provides: diff --git a/lib/Lutim.pm b/lib/Lutim.pm index b8cd1cc..c00f295 100644 --- a/lib/Lutim.pm +++ b/lib/Lutim.pm @@ -3,6 +3,7 @@ package Lutim; use Mojo::Base 'Mojolicious'; use Mojo::IOLoop; use Lutim::DB::Image; +use CHI; use vars qw($im_loaded); BEGIN { @@ -52,9 +53,19 @@ sub startup { dbtype => 'sqlite', db_path => 'minion.db' }, + cache_max_size => 0, } }); + my $cache_max_size = ($config->{cache_max_size} > 0) ? 8 * 1024 * 1024 * $config->{cache_max_size} : 1; + $self->{images_cache} = CHI->new( + driver => 'Memory', + global => 1, + is_size_aware => 1, + max_size => $cache_max_size, + expires_in => '1 day' + ); + die "You need to provide a contact information in lutim.conf !" unless (defined($config->{contact})); $ENV{MOJO_MAX_MESSAGE_SIZE} = $config->{max_file_size}; diff --git a/lib/Lutim/Plugin/Helpers.pm b/lib/Lutim/Plugin/Helpers.pm index 25c13f3..4d5977b 100644 --- a/lib/Lutim/Plugin/Helpers.pm +++ b/lib/Lutim/Plugin/Helpers.pm @@ -2,6 +2,7 @@ package Lutim::Plugin::Helpers; use Mojo::Base 'Mojolicious::Plugin'; use Mojo::Util qw(quote); +use Mojo::File; use Crypt::CBC; use Data::Entropy qw(entropy_source); use DateTime; @@ -77,7 +78,6 @@ sub _render_file { $dl = 'attachment' if ($mediatype =~ m/svg/); $filename = quote($filename); - my $asset; unless (-f $path && -r $path) { $c->app->log->error("Cannot read file [$path]. error [$!]"); $c->flash( @@ -98,11 +98,30 @@ sub _render_file { $headers->add('Content-Disposition' => $dl.';filename='.$filename); $c->res->content->headers($headers); - if ($key) { - $asset = $c->decrypt($key, $path, $iv); - } else { - $asset = Mojo::Asset::File->new(path => $path); + my $cache = $c->app->{images_cache}->compute($img->short, undef, sub { + if ($key) { + return { + asset => $c->decrypt($key, $path, $iv), + key => $key + }; + } else { + return { + asset => Mojo::File->new($path)->slurp, + }; + } + }); + if ($key && $key ne $cache->{key}) { + $c->app->{images_cache}->replace( + $img->short, + { + asset => $c->decrypt($key, $path, $iv), + key => $key + }, + ); } + # Extend expiration time + my $asset = Mojo::Asset::Memory->new; + $asset->add_chunk($cache->{asset}); if (defined $thumb && $im_loaded && $mediatype ne 'image/svg+xml' && $mediatype !~ m#image/(x-)?xcf# && $mediatype ne 'image/webp') { # ImageMagick don't work in Debian with svg (for now?) my $im = Image::Magick->new; @@ -261,17 +280,20 @@ sub _decrypt { open(my $f, "<",$file) or die "Unable to read encrypted file: $!"; binmode $f; - while (read($f, my $buffer,1024)) { + while (read($f, my $buffer, 1024)) { $decrypt_asset->add_chunk($cipher->crypt($buffer)); } $decrypt_asset->add_chunk($cipher->finish) ; - return $decrypt_asset; + return $decrypt_asset->slurp; } sub _delete_image { my $c = shift; my $img = shift; + if ($c->app->{images_cache}) { + $c->app->{images_cache}->remove($img->short); + } unlink $img->path or warn "Could not unlink ".$img->path.": $!"; $img->disable(); } diff --git a/lib/Mounter.pm b/lib/Mounter.pm index 748f6a2..32ef5d0 100644 --- a/lib/Mounter.pm +++ b/lib/Mounter.pm @@ -46,6 +46,7 @@ sub startup { dbtype => 'sqlite', db_path => 'minion.db' }, + cache_max_size => 0, } } ); diff --git a/lutim.conf.template b/lutim.conf.template index 46eb95f..0408d12 100644 --- a/lutim.conf.template +++ b/lutim.conf.template @@ -92,7 +92,7 @@ # comma-separated values proposed for delays # optional, default is '0,1,7,30,365' #proposed_delays => '0,1,7,30,365', - + # number of days after which the images will be deleted, even if they were uploaded with "no delay" (or value superior to max_delay) # a warning message will be displayed on homepage # optional, default is 0 (no limit) @@ -175,6 +175,13 @@ # optional, default is 15 #max_files_in_zip => 15, + # maximum size (in MB) of memory allowed for the image cache + # Lutim has a built-in memory-based image cache to accelerate responses to often-viewed images. + # This setting makes the cache remove oldest viewed image if the cache size is over it. + # If set to 0, the cache is disabled + # optional, default is 0 + #cache_max_size => 0, + ########################## # Lutim cron jobs settings ########################## diff --git a/t/postgresql1.conf b/t/postgresql1.conf index 9d7fe63..62f0d1a 100644 --- a/t/postgresql1.conf +++ b/t/postgresql1.conf @@ -89,6 +89,10 @@ # optional, default is 0 (no limit) default_delay => 30, + # comma-separated values proposed for delays + # optional, default is '0,1,7,30,365' + #proposed_delays => '0,1,7,30,365', + # number of days after which the images will be deleted, even if they were uploaded with "no delay" (or value superior to max_delay) # a warning message will be displayed on homepage # optional, default is 0 (no limit) @@ -171,6 +175,13 @@ # optional, default is 15 #max_files_in_zip => 15, + # maximum size (in MB) of memory allowed for the image cache + # Lutim has a built-in memory-based image cache to accelerate responses to often-viewed images. + # This setting makes the cache remove oldest viewed image if the cache size is over it. + # If set to 0, the cache is disabled + # optional, default is 0 + #cache_max_size => 0, + ########################## # Lutim cron jobs settings ########################## diff --git a/t/postgresql2.conf b/t/postgresql2.conf index 452e6ca..008d01d 100644 --- a/t/postgresql2.conf +++ b/t/postgresql2.conf @@ -89,6 +89,10 @@ # optional, default is 0 (no limit) default_delay => 30, + # comma-separated values proposed for delays + # optional, default is '0,1,7,30,365' + #proposed_delays => '0,1,7,30,365', + # number of days after which the images will be deleted, even if they were uploaded with "no delay" (or value superior to max_delay) # a warning message will be displayed on homepage # optional, default is 0 (no limit) @@ -171,6 +175,13 @@ # optional, default is 15 #max_files_in_zip => 15, + # maximum size (in MB) of memory allowed for the image cache + # Lutim has a built-in memory-based image cache to accelerate responses to often-viewed images. + # This setting makes the cache remove oldest viewed image if the cache size is over it. + # If set to 0, the cache is disabled + # optional, default is 0 + #cache_max_size => 0, + ########################## # Lutim cron jobs settings ########################## diff --git a/t/postgresql3.conf b/t/postgresql3.conf index a8a5810..dd81819 100644 --- a/t/postgresql3.conf +++ b/t/postgresql3.conf @@ -89,6 +89,10 @@ # optional, default is 0 (no limit) default_delay => 30, + # comma-separated values proposed for delays + # optional, default is '0,1,7,30,365' + #proposed_delays => '0,1,7,30,365', + # number of days after which the images will be deleted, even if they were uploaded with "no delay" (or value superior to max_delay) # a warning message will be displayed on homepage # optional, default is 0 (no limit) @@ -171,6 +175,13 @@ # optional, default is 15 #max_files_in_zip => 15, + # maximum size (in MB) of memory allowed for the image cache + # Lutim has a built-in memory-based image cache to accelerate responses to often-viewed images. + # This setting makes the cache remove oldest viewed image if the cache size is over it. + # If set to 0, the cache is disabled + # optional, default is 0 + #cache_max_size => 0, + ########################## # Lutim cron jobs settings ########################## diff --git a/t/sqlite1.conf b/t/sqlite1.conf index 53348e7..1b555e7 100644 --- a/t/sqlite1.conf +++ b/t/sqlite1.conf @@ -89,6 +89,10 @@ # optional, default is 0 (no limit) default_delay => 30, + # comma-separated values proposed for delays + # optional, default is '0,1,7,30,365' + #proposed_delays => '0,1,7,30,365', + # number of days after which the images will be deleted, even if they were uploaded with "no delay" (or value superior to max_delay) # a warning message will be displayed on homepage # optional, default is 0 (no limit) @@ -171,6 +175,13 @@ # optional, default is 15 #max_files_in_zip => 15, + # maximum size (in MB) of memory allowed for the image cache + # Lutim has a built-in memory-based image cache to accelerate responses to often-viewed images. + # This setting makes the cache remove oldest viewed image if the cache size is over it. + # If set to 0, the cache is disabled + # optional, default is 0 + #cache_max_size => 0, + ########################## # Lutim cron jobs settings ########################## diff --git a/t/sqlite2.conf b/t/sqlite2.conf index e4c6a12..e80a1f0 100644 --- a/t/sqlite2.conf +++ b/t/sqlite2.conf @@ -89,6 +89,10 @@ # optional, default is 0 (no limit) default_delay => 30, + # comma-separated values proposed for delays + # optional, default is '0,1,7,30,365' + #proposed_delays => '0,1,7,30,365', + # number of days after which the images will be deleted, even if they were uploaded with "no delay" (or value superior to max_delay) # a warning message will be displayed on homepage # optional, default is 0 (no limit) @@ -171,6 +175,13 @@ # optional, default is 15 #max_files_in_zip => 15, + # maximum size (in MB) of memory allowed for the image cache + # Lutim has a built-in memory-based image cache to accelerate responses to often-viewed images. + # This setting makes the cache remove oldest viewed image if the cache size is over it. + # If set to 0, the cache is disabled + # optional, default is 0 + #cache_max_size => 0, + ########################## # Lutim cron jobs settings ########################## diff --git a/t/sqlite3.conf b/t/sqlite3.conf index dea2e0b..65d142a 100644 --- a/t/sqlite3.conf +++ b/t/sqlite3.conf @@ -89,6 +89,10 @@ # optional, default is 0 (no limit) default_delay => 30, + # comma-separated values proposed for delays + # optional, default is '0,1,7,30,365' + #proposed_delays => '0,1,7,30,365', + # number of days after which the images will be deleted, even if they were uploaded with "no delay" (or value superior to max_delay) # a warning message will be displayed on homepage # optional, default is 0 (no limit) @@ -171,6 +175,13 @@ # optional, default is 15 #max_files_in_zip => 15, + # maximum size (in MB) of memory allowed for the image cache + # Lutim has a built-in memory-based image cache to accelerate responses to often-viewed images. + # This setting makes the cache remove oldest viewed image if the cache size is over it. + # If set to 0, the cache is disabled + # optional, default is 0 + #cache_max_size => 0, + ########################## # Lutim cron jobs settings ########################## diff --git a/t/test.t b/t/test.t index 83aee73..8c37ae1 100644 --- a/t/test.t +++ b/t/test.t @@ -26,12 +26,35 @@ BEGIN { { file => $cfile->to_abs->to_string, default => { - dbtype => 'sqlite' + provisioning => 100, + provis_step => 5, + length => 8, + always_encrypt => 0, + anti_flood_delay => 5, + tweet_card_via => '@framasky', + max_file_size => 10*1024*1024, + https => 0, + proposed_delays => '0,1,7,30,365', + default_delay => 0, + max_delay => 0, + token_length => 24, + crypto_key_length => 8, + thumbnail_size => 100, + theme => 'default', + dbtype => 'sqlite', + db_path => 'lutim.db', + max_files_in_zip => 15, + prefix => '/', + minion => { + enabled => 0, + dbtype => 'sqlite', + db_path => 'minion.db' + }, + cache_max_size => 0, } } ); $m->plugin('Lutim::Plugin::Helpers'); - $m->plugin('DebugDumperHelper'); } # Home page diff --git a/themes/default/lib/Lutim/I18N/lutim.pot b/themes/default/lib/Lutim/I18N/lutim.pot index acd6efd..eeabf7d 100644 --- a/themes/default/lib/Lutim/I18N/lutim.pot +++ b/themes/default/lib/Lutim/I18N/lutim.pot @@ -32,11 +32,11 @@ msgstr "" msgid "-or-" msgstr "" -#: lib/Lutim.pm:188 lib/Lutim/Command/cron/stats.pm:151 lib/Lutim/Command/cron/stats.pm:162 lib/Lutim/Command/cron/stats.pm:179 themes/default/templates/index.html.ep:5 themes/default/templates/raw.html.ep:10 themes/default/templates/raw.html.ep:21 themes/default/templates/raw.html.ep:38 +#: lib/Lutim.pm:199 lib/Lutim/Command/cron/stats.pm:151 lib/Lutim/Command/cron/stats.pm:162 lib/Lutim/Command/cron/stats.pm:179 themes/default/templates/index.html.ep:5 themes/default/templates/raw.html.ep:10 themes/default/templates/raw.html.ep:21 themes/default/templates/raw.html.ep:38 msgid "1 year" msgstr "" -#: lib/Lutim.pm:187 lib/Lutim/Command/cron/stats.pm:148 lib/Lutim/Command/cron/stats.pm:159 lib/Lutim/Command/cron/stats.pm:176 themes/default/templates/index.html.ep:4 themes/default/templates/partial/for_my_delay.html.ep:13 themes/default/templates/partial/lutim.js.ep:151 themes/default/templates/raw.html.ep:18 themes/default/templates/raw.html.ep:35 themes/default/templates/raw.html.ep:7 +#: lib/Lutim.pm:198 lib/Lutim/Command/cron/stats.pm:148 lib/Lutim/Command/cron/stats.pm:159 lib/Lutim/Command/cron/stats.pm:176 themes/default/templates/index.html.ep:4 themes/default/templates/partial/for_my_delay.html.ep:13 themes/default/templates/partial/lutim.js.ep:151 themes/default/templates/raw.html.ep:18 themes/default/templates/raw.html.ep:35 themes/default/templates/raw.html.ep:7 msgid "24 hours" msgstr "" @@ -443,7 +443,7 @@ msgid "Uploaded files by days" msgstr "" #. ($c->app->config('contact') -#: lib/Lutim/Plugin/Helpers.pm:183 +#: lib/Lutim/Plugin/Helpers.pm:202 msgid "Uploading is currently disabled, please try later or contact the administrator (%1)." msgstr "" @@ -495,7 +495,7 @@ msgstr "" msgid "core developer" msgstr "" -#: lib/Lutim.pm:186 lib/Lutim/Command/cron/stats.pm:147 lib/Lutim/Command/cron/stats.pm:158 lib/Lutim/Command/cron/stats.pm:175 themes/default/templates/index.html.ep:3 themes/default/templates/raw.html.ep:17 themes/default/templates/raw.html.ep:34 themes/default/templates/raw.html.ep:6 +#: lib/Lutim.pm:197 lib/Lutim/Command/cron/stats.pm:147 lib/Lutim/Command/cron/stats.pm:158 lib/Lutim/Command/cron/stats.pm:175 themes/default/templates/index.html.ep:3 themes/default/templates/raw.html.ep:17 themes/default/templates/raw.html.ep:34 themes/default/templates/raw.html.ep:6 msgid "no time limit" msgstr ""