summaryrefslogtreecommitdiff
path: root/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php
blob: 38b061dcf12e53009677bb869da16e27b64dd108 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php

use Smarty\Smarty;
use Smarty\Template;
use Smarty\Template\Cached;

require_once __DIR__ . '/../../../__shared/cacheresources/cacheresource.apc.php';

class Smarty_CacheResource_Apctest extends Smarty_CacheResource_Apc
{
    public $lockTime = 0;

    public function hasLock(Smarty $smarty, Cached $cached)
    {
        if ($this->lockTime) {
            $this->lockTime--;
            if (!$this->lockTime) {
                $this->releaseLock($smarty, $cached);
            }
        }
        return parent::hasLock($smarty, $cached);
    }

    public function get(Template $_template)
    {
        $this->contents = array();
        $this->timestamps = array();
        $t = $this->getContent($_template);

        return $t ? $t : null;
    }

}