Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12944340
CacheFactory.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
CacheFactory.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Keruald\Cache
;
use
Keruald\Cache\Engines\CacheVoid
;
use
Keruald\Cache\Exceptions\CacheException
;
/**
* Cache caller
*/
class
CacheFactory
{
const
DEFAULT_ENGINE
=
CacheVoid
::
class
;
/**
* Loads the cache instance, building it according a configuration array.
*
* The correct cache instance to initialize will be determined from the
* 'engine' key. It should match the name of a Cache class.
*
* This method will create an instance of the specified object,
* calling the load static method from this object class.
*
* Example:
* <code>
* $config['engine'] = CacheQuux::class;
* $cache = Cache::load($config); //Cache:load() will call CacheQuux:load();
* </code>
*
* @return Cache the cache instance
* @throws CacheException
*/
static
function
load
(
array
$config
)
:
Cache
{
$engine
=
$config
[
"engine"
]
??
self
::
DEFAULT_ENGINE
;
if
(!
class_exists
(
$engine
))
{
throw
new
CacheException
(
"Can't initialize $engine cache engine. The class can't be found."
);
}
return
call_user_func
([
$engine
,
'load'
],
$config
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Nov 18, 17:14 (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3146394
Default Alt Text
CacheFactory.php (1 KB)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment