aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/config/config.yml1
-rw-r--r--app/config/config_dev.yml8
-rw-r--r--src/Wallabag/CoreBundle/DependencyInjection/Configuration.php3
-rw-r--r--src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php1
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php11
-rw-r--r--src/Wallabag/CoreBundle/Resources/config/services.yml2
6 files changed, 24 insertions, 2 deletions
diff --git a/app/config/config.yml b/app/config/config.yml
index 80754393..eb53fc5d 100644
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -49,6 +49,7 @@ wallabag_core:
49 language: en 49 language: en
50 rss_limit: 50 50 rss_limit: 50
51 reading_speed: 1 51 reading_speed: 1
52 cache_lifetime: 10
52 53
53wallabag_import: 54wallabag_import:
54 allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain'] 55 allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain']
diff --git a/app/config/config_dev.yml b/app/config/config_dev.yml
index 77840682..3b67d8f6 100644
--- a/app/config/config_dev.yml
+++ b/app/config/config_dev.yml
@@ -40,3 +40,11 @@ swiftmailer:
40 transport: smtp 40 transport: smtp
41 host: 'localhost' 41 host: 'localhost'
42 port: 1025 42 port: 1025
43
44# If you want to use cache for queries used in WallabagExtension
45# Uncomment the following lines
46#doctrine:
47# orm:
48# metadata_cache_driver: apcu
49# result_cache_driver: apcu
50# query_cache_driver: apcu
diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php
index d1bb9820..d8141eea 100644
--- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php
+++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php
@@ -36,6 +36,9 @@ class Configuration implements ConfigurationInterface
36 ->end() 36 ->end()
37 ->scalarNode('paypal_url') 37 ->scalarNode('paypal_url')
38 ->end() 38 ->end()
39 ->integerNode('cache_lifetime')
40 ->defaultValue(10)
41 ->end()
39 ->end() 42 ->end()
40 ; 43 ;
41 44
diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
index 7d08b73b..0cbde908 100644
--- a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
+++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
@@ -22,6 +22,7 @@ class WallabagCoreExtension extends Extension
22 $container->setParameter('wallabag_core.reading_speed', $config['reading_speed']); 22 $container->setParameter('wallabag_core.reading_speed', $config['reading_speed']);
23 $container->setParameter('wallabag_core.version', $config['version']); 23 $container->setParameter('wallabag_core.version', $config['version']);
24 $container->setParameter('wallabag_core.paypal_url', $config['paypal_url']); 24 $container->setParameter('wallabag_core.paypal_url', $config['paypal_url']);
25 $container->setParameter('wallabag_core.cache_lifetime', $config['cache_lifetime']);
25 26
26 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); 27 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
27 $loader->load('services.yml'); 28 $loader->load('services.yml');
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 86bce545..4b205f6e 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -10,6 +10,8 @@ use Wallabag\CoreBundle\Entity\Tag;
10 10
11class EntryRepository extends EntityRepository 11class EntryRepository extends EntityRepository
12{ 12{
13 private $lifeTime;
14
13 /** 15 /**
14 * Return a query builder to used by other getBuilderFor* method. 16 * Return a query builder to used by other getBuilderFor* method.
15 * 17 *
@@ -281,8 +283,13 @@ class EntryRepository extends EntityRepository
281 return $qb->getQuery()->getSingleScalarResult(); 283 return $qb->getQuery()->getSingleScalarResult();
282 } 284 }
283 285
286 public function setLifeTime($lifeTime)
287 {
288 $this->lifeTime = $lifeTime;
289 }
290
284 /** 291 /**
285 * Enable cache for a query 292 * Enable cache for a query.
286 * 293 *
287 * @param Query $query 294 * @param Query $query
288 * 295 *
@@ -292,7 +299,7 @@ class EntryRepository extends EntityRepository
292 { 299 {
293 $query->useQueryCache(true); 300 $query->useQueryCache(true);
294 $query->useResultCache(true); 301 $query->useResultCache(true);
295 $query->setResultCacheLifetime(5); 302 $query->setResultCacheLifetime($this->lifeTime);
296 303
297 return $query; 304 return $query;
298 } 305 }
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml
index f8835198..b70d9b8c 100644
--- a/src/Wallabag/CoreBundle/Resources/config/services.yml
+++ b/src/Wallabag/CoreBundle/Resources/config/services.yml
@@ -81,6 +81,8 @@ services:
81 factory: [ "@doctrine.orm.default_entity_manager", getRepository ] 81 factory: [ "@doctrine.orm.default_entity_manager", getRepository ]
82 arguments: 82 arguments:
83 - WallabagCoreBundle:Entry 83 - WallabagCoreBundle:Entry
84 calls:
85 - [ setLifeTime, [ "%wallabag_core.cache_lifetime%" ] ]
84 86
85 wallabag_core.tag_repository: 87 wallabag_core.tag_repository:
86 class: Wallabag\CoreBundle\Repository\TagRepository 88 class: Wallabag\CoreBundle\Repository\TagRepository