Ubiquity
2.5.2
php rapid development framework
Loading...
Searching...
No Matches
DAOSerialCache.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Ubiquity\cache\dao
;
4
5
use
Ubiquity\cache\CacheManager
;
6
use
Ubiquity\contents\serializers\SerializerInterface
;
7
use
Ubiquity\contents\serializers\PhpSerializer
;
8
use
Ubiquity\cache\system\AbstractDataCache
;
9
use Ubiquity\cache\system\ArrayCache;
10
19
class
DAOSerialCache
extends
AbstractDAOCache
{
20
25
protected
$serializer
;
26
31
protected
$cache
;
32
33
protected
function
getKey
($class, $key) {
34
return \md5 ( $class . $key );
35
}
36
37
public
function
__construct
($cacheSystem = ArrayCache::class,
$serializer
= PhpSerializer::class) {
38
if
(\is_string ( $cacheSystem )) {
39
$this->cache =
new
$cacheSystem (
CacheManager::getCacheSubDirectory
(
'objects'
),
'.object'
);
40
}
else
{
41
$this->cache = $cacheSystem;
42
}
43
$this->serializer =
new
$serializer
();
44
}
45
46
public
function
store
($class, $key, $object) {
47
$this->cache->store ( $this->
getKey
( $class, $key ), $this->serializer->serialize ( $object ) );
48
}
49
50
public
function
fetch
($class, $key) {
51
$result = $this->cache->fetch ( $this->
getKey
( $class, $key ) );
52
if
($result) {
53
return
$this->serializer->unserialize ( $result );
54
}
55
return
false
;
56
}
57
58
public
function
delete
($class, $key) {
59
$key = $this->
getKey
( $class, $key );
60
if
($this->cache->exists ( $key )) {
61
return
$this->cache->remove ( $key );
62
}
63
return
false
;
64
}
65
}
66
Ubiquity\cache\CacheManager
Manager for caches (Router, Rest, models).
Definition
CacheManager.php:28
Ubiquity\cache\CacheManager\getCacheSubDirectory
static getCacheSubDirectory(string $subDirectory)
Returns an absolute cache subdirectory.
Definition
CacheManager.php:94
Ubiquity\cache\dao\AbstractDAOCache
Ubiquity\cache\dao$AbstractDAOCache This class is part of Ubiquity.
Definition
AbstractDAOCache.php:13
Ubiquity\cache\dao\DAOSerialCache
Ubiquity\cache\dao$DAOSerialCache This class is part of Ubiquity.
Definition
DAOSerialCache.php:19
Ubiquity\cache\dao\DAOSerialCache\$serializer
$serializer
Definition
DAOSerialCache.php:25
Ubiquity\cache\dao\DAOSerialCache\store
store($class, $key, $object)
Definition
DAOSerialCache.php:46
Ubiquity\cache\dao\DAOSerialCache\__construct
__construct($cacheSystem=ArrayCache::class, $serializer=PhpSerializer::class)
Definition
DAOSerialCache.php:37
Ubiquity\cache\dao\DAOSerialCache\getKey
getKey($class, $key)
Definition
DAOSerialCache.php:33
Ubiquity\cache\dao\DAOSerialCache\$cache
$cache
Definition
DAOSerialCache.php:31
Ubiquity\cache\dao\DAOSerialCache\fetch
fetch($class, $key)
Definition
DAOSerialCache.php:50
Ubiquity\cache\system\AbstractDataCache
This class is responsible for storing Arrays in PHP files.
Definition
AbstractDataCache.php:21
Ubiquity\contents\serializers\PhpSerializer
Ubiquity\contents\serializers$PhpSerializer This class is part of Ubiquity.
Definition
PhpSerializer.php:13
Ubiquity\contents\serializers\SerializerInterface
Ubiquity\contents\serializers$SerializerInterface This class is part of Ubiquity.
Definition
SerializerInterface.php:13
Ubiquity\cache\dao
Definition
AbstractDAOCache.php:3
C:
Users
myadd
Documents
GitHub
ubiquity-doc-api
vendor
phpmv
ubiquity
src
Ubiquity
cache
dao
DAOSerialCache.php
Generated on Sun Dec 10 2023 15:04:11 for
Ubiquity
by
doxygen
1.9.8