Last active
October 6, 2016 11:56
-
-
Save nicomen/bf527b8085f4986eed71fafaf9bca709 to your computer and use it in GitHub Desktop.
Move cache driver setup to config and allow forcing no cache with envvar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/lib/Reisegiganten.pm b/lib/Reisegiganten.pm | |
| index 31fd492..5614df3 100644 | |
| --- a/lib/Reisegiganten.pm | |
| +++ b/lib/Reisegiganten.pm | |
| @@ -188,7 +188,7 @@ sub setup_attrs { | |
| my ($self) = @_; | |
| $self->attr( 'db_config' => sub { RG::Config->new; }); | |
| - $self->attr( 'cache' => sub { CHI->new( driver => 'FastMmap', cache_size => '10m', root_dir => '/tmp/mmap_' . __PACKAGE__, expire_time => '10m', expires_in => '10 min', expires_variance => 0.1 )}); | |
| + $self->attr( 'cache' => sub { CHI->new( $ENV{NO_CACHE} ? ( Driver => 'Null' ) : $self->config->{cache} ) }); | |
| $self->cache->clear unless $ENV{KEEP_CACHE}; | |
| $self->attr( 'db_model' => sub { Reisegiganten::DBModel->new; }); | |
| $self->attr( 'rg_supplier' => sub { RG::Supplier->new; }); | |
| diff --git a/share/reisegiganten.conf b/share/reisegiganten.conf | |
| index cc9ec41..5fa38aa 100644 | |
| --- a/share/reisegiganten.conf | |
| +++ b/share/reisegiganten.conf | |
| @@ -162,3 +162,16 @@ destination_news http://nyheter.destination.se/feed | |
| flight flight | |
| lms lms | |
| </seo2cms> | |
| + | |
| +<cache> | |
| + <l1_cache> | |
| + driver FastMmap | |
| + cache_size 10m | |
| + root_dir /tmp/mmap_reisegiganten | |
| + expire_time 10m | |
| + expires_in 10 min | |
| + expires_variance 0.1 | |
| + </l1_cache> | |
| + driver Memcached::libmemcached | |
| + servers dev:11211 | |
| +</cache> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment