1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-07-22 17:18:37 +00:00

Store cache lifetime in config

This commit is contained in:
Nicolas Lœuillet 2016-09-03 14:02:50 +02:00
parent 0b0233b1ec
commit b3f4a11a81
No known key found for this signature in database
GPG key ID: 5656BE27E1E34D0A
6 changed files with 24 additions and 2 deletions

View file

@ -49,6 +49,7 @@ wallabag_core:
language: en language: en
rss_limit: 50 rss_limit: 50
reading_speed: 1 reading_speed: 1
cache_lifetime: 10
wallabag_import: wallabag_import:
allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain'] allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain']

View file

@ -40,3 +40,11 @@ swiftmailer:
transport: smtp transport: smtp
host: 'localhost' host: 'localhost'
port: 1025 port: 1025
# If you want to use cache for queries used in WallabagExtension
# Uncomment the following lines
#doctrine:
# orm:
# metadata_cache_driver: apcu
# result_cache_driver: apcu
# query_cache_driver: apcu

View file

@ -36,6 +36,9 @@ class Configuration implements ConfigurationInterface
->end() ->end()
->scalarNode('paypal_url') ->scalarNode('paypal_url')
->end() ->end()
->integerNode('cache_lifetime')
->defaultValue(10)
->end()
->end() ->end()
; ;

View file

@ -22,6 +22,7 @@ class WallabagCoreExtension extends Extension
$container->setParameter('wallabag_core.reading_speed', $config['reading_speed']); $container->setParameter('wallabag_core.reading_speed', $config['reading_speed']);
$container->setParameter('wallabag_core.version', $config['version']); $container->setParameter('wallabag_core.version', $config['version']);
$container->setParameter('wallabag_core.paypal_url', $config['paypal_url']); $container->setParameter('wallabag_core.paypal_url', $config['paypal_url']);
$container->setParameter('wallabag_core.cache_lifetime', $config['cache_lifetime']);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml'); $loader->load('services.yml');

View file

@ -10,6 +10,8 @@ use Wallabag\CoreBundle\Entity\Tag;
class EntryRepository extends EntityRepository class EntryRepository extends EntityRepository
{ {
private $lifeTime;
/** /**
* Return a query builder to used by other getBuilderFor* method. * Return a query builder to used by other getBuilderFor* method.
* *
@ -281,8 +283,13 @@ class EntryRepository extends EntityRepository
return $qb->getQuery()->getSingleScalarResult(); return $qb->getQuery()->getSingleScalarResult();
} }
public function setLifeTime($lifeTime)
{
$this->lifeTime = $lifeTime;
}
/** /**
* Enable cache for a query * Enable cache for a query.
* *
* @param Query $query * @param Query $query
* *
@ -292,7 +299,7 @@ class EntryRepository extends EntityRepository
{ {
$query->useQueryCache(true); $query->useQueryCache(true);
$query->useResultCache(true); $query->useResultCache(true);
$query->setResultCacheLifetime(5); $query->setResultCacheLifetime($this->lifeTime);
return $query; return $query;
} }

View file

@ -81,6 +81,8 @@ services:
factory: [ "@doctrine.orm.default_entity_manager", getRepository ] factory: [ "@doctrine.orm.default_entity_manager", getRepository ]
arguments: arguments:
- WallabagCoreBundle:Entry - WallabagCoreBundle:Entry
calls:
- [ setLifeTime, [ "%wallabag_core.cache_lifetime%" ] ]
wallabag_core.tag_repository: wallabag_core.tag_repository:
class: Wallabag\CoreBundle\Repository\TagRepository class: Wallabag\CoreBundle\Repository\TagRepository