Completed
Push — inmemory-fixes ( e7c94b...411b2d )
by André
29:42 queued 09:14
created

TransactionHandler::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the Persistence Transaction Cache Handler class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\Persistence\Cache;
10
11
use eZ\Publish\SPI\Persistence\TransactionHandler as TransactionHandlerInterface;
12
13
/**
14
 * Persistence Transaction Cache Handler class.
15
 */
16
class TransactionHandler extends AbstractInMemoryHandler implements TransactionHandlerInterface
17
{
18
    /**
19
     * @todo Maybe this can be solved by contributing to Symfony, as in for instance using a layered cache with memory
20
     * cache first and use saveDefered so cache is not persisted before commit is made, and omitted on rollback.
21
     *
22
     * Or if we can get a checksum /fingerprint from cache pool which changes on actually cache commit so we can
23
     * keep track to see if it has changed (to know if it is enough to clear inMemory cache + cache pool defer que)
24
     *
25
     * {@inheritdoc}
26
     */
27
    public function beginTransaction()
28
    {
29
        $this->logger->logCall(__METHOD__);
30
        $this->persistenceHandler->transactionHandler()->beginTransaction();
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function commit()
37
    {
38
        $this->logger->logCall(__METHOD__);
39
        $this->persistenceHandler->transactionHandler()->commit();
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function rollback()
46
    {
47
        $this->logger->logCall(__METHOD__);
48
        $this->clearCache(); // TIMBER!! @see beginTransaction()
49
        $this->persistenceHandler->transactionHandler()->rollback();
50
    }
51
}
52