CacheConfiguration.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /*
  3. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  4. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  5. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  6. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  8. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. *
  15. * This software consists of voluntary contributions made by many individuals
  16. * and is licensed under the MIT license. For more information, see
  17. * <http://www.doctrine-project.org>.
  18. */
  19. namespace Doctrine\ORM\Cache;
  20. use Doctrine\ORM\Cache\Logging\CacheLogger;
  21. /**
  22. * Configuration container for second-level cache.
  23. */
  24. class CacheConfiguration
  25. {
  26. /** @var CacheFactory|null */
  27. private $cacheFactory;
  28. /** @var RegionsConfiguration|null */
  29. private $regionsConfig;
  30. /** @var CacheLogger|null */
  31. private $cacheLogger;
  32. /** @var QueryCacheValidator|null */
  33. private $queryValidator;
  34. /**
  35. * @return CacheFactory|null
  36. */
  37. public function getCacheFactory()
  38. {
  39. return $this->cacheFactory;
  40. }
  41. /**
  42. * @return void
  43. */
  44. public function setCacheFactory(CacheFactory $factory)
  45. {
  46. $this->cacheFactory = $factory;
  47. }
  48. /**
  49. * @return CacheLogger|null
  50. */
  51. public function getCacheLogger()
  52. {
  53. return $this->cacheLogger;
  54. }
  55. public function setCacheLogger(CacheLogger $logger)
  56. {
  57. $this->cacheLogger = $logger;
  58. }
  59. /**
  60. * @return RegionsConfiguration
  61. */
  62. public function getRegionsConfiguration()
  63. {
  64. if ($this->regionsConfig === null) {
  65. $this->regionsConfig = new RegionsConfiguration();
  66. }
  67. return $this->regionsConfig;
  68. }
  69. public function setRegionsConfiguration(RegionsConfiguration $regionsConfig)
  70. {
  71. $this->regionsConfig = $regionsConfig;
  72. }
  73. /**
  74. * @return QueryCacheValidator
  75. */
  76. public function getQueryValidator()
  77. {
  78. if ($this->queryValidator === null) {
  79. $this->queryValidator = new TimestampQueryCacheValidator(
  80. $this->cacheFactory->getTimestampRegion()
  81. );
  82. }
  83. return $this->queryValidator;
  84. }
  85. public function setQueryValidator(QueryCacheValidator $validator)
  86. {
  87. $this->queryValidator = $validator;
  88. }
  89. }