aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
4 files changed, 15 insertions, 2 deletions
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