MagratheaCache
extends Singleton
in package
MagratheaCache: cache static responses to save some processing time
Table of Contents
Properties
- $cacheName : mixed
- $saveCache : bool
- $instance : array<string|int, mixed>|null
- $cachePath : mixed
- $extension : mixed
Methods
- __wakeup() : mixed
- Cache() : mixed
- Initiates the cache and displays the cached data if already available (killing the execution)
- Clear() : mixed
- Clears cache for given cache name
- DeleteFile() : mixed
- Deletes a file from cache
- GetCacheFile() : string
- Get full cache file path
- GetCachePath() : string
- Gets the path where cached files will be stored
- HandleApiCache() : mixed
- Handles data from the API to save it on cache and displays it, killing the execution
- Initialize() : mixed
- Instance() : static|Singleton
- LoadCachePath() : MagratheaCache
- Loads the cache path from config file
- LookForFile() : mixed
- Checks if the cached file exists.
- MockClass() : static|Singleton
- RemoveAllCache() : array<string|int, mixed>
- deletes all files from cached path
- RemovePattern() : array<string|int, mixed>
- deletes files with pattern
- SaveFile() : mixed
- Saves cache file info
- SetInstance() : mixed
- ShowJson() : mixed
- Shows a json and kills execution
- Type() : MagratheaCache
- Sets the type of cached file (html, json, txt, etc)
- __clone() : mixed
- __construct() : mixed
- CreateHandle() : mixed
Properties
$cacheName
public
mixed
$cacheName
$saveCache
public
bool
$saveCache
= false
$instance
protected
static array<string|int, mixed>|null
$instance
= []
$cachePath
private
mixed
$cachePath
$extension
private
mixed
$extension
= "json"
Methods
__wakeup()
public
final __wakeup() : mixed
Cache()
Initiates the cache and displays the cached data if already available (killing the execution)
public
Cache( $name[, $data = null ]) : mixed
Parameters
Clear()
Clears cache for given cache name
public
Clear( $name[, $data = null ]) : mixed
Parameters
DeleteFile()
Deletes a file from cache
public
DeleteFile(string $file[, bool $addExtension = true ]) : mixed
Parameters
- $file : string
- $addExtension : bool = true
GetCacheFile()
Get full cache file path
public
GetCacheFile() : string
Return values
string —path
GetCachePath()
Gets the path where cached files will be stored
public
GetCachePath() : string
Return values
stringHandleApiCache()
Handles data from the API to save it on cache and displays it, killing the execution
public
HandleApiCache(array<string|int, mixed> $data) : mixed
Parameters
- $data : array<string|int, mixed>
Initialize()
public
Initialize() : mixed
Instance()
public
static Instance() : static|Singleton
Return values
static|SingletonLoadCachePath()
Loads the cache path from config file
public
LoadCachePath() : MagratheaCache
Return values
MagratheaCache —itself
LookForFile()
Checks if the cached file exists.
public
LookForFile() : mixed
Displays it if does (and kills execution)
MockClass()
public
static MockClass(mixed $mocker) : static|Singleton
Parameters
- $mocker : mixed
Return values
static|SingletonRemoveAllCache()
deletes all files from cached path
public
RemoveAllCache() : array<string|int, mixed>
Return values
array<string|int, mixed> —deleted files
RemovePattern()
deletes files with pattern
public
RemovePattern(string $pattern) : array<string|int, mixed>
Parameters
- $pattern : string
Return values
array<string|int, mixed> —deleted files
SaveFile()
Saves cache file info
public
SaveFile(string $data) : mixed
Parameters
- $data : string
SetInstance()
public
SetInstance(mixed $inst) : mixed
Parameters
- $inst : mixed
ShowJson()
Shows a json and kills execution
public
ShowJson(array<string|int, mixed>|string $data) : mixed
Parameters
- $data : array<string|int, mixed>|string
Type()
Sets the type of cached file (html, json, txt, etc)
public
Type(string $t) : MagratheaCache
Parameters
- $t : string
Return values
MagratheaCache —itself
__clone()
protected
final __clone() : mixed
__construct()
private
final __construct() : mixed
CreateHandle()
private
CreateHandle(string $name[, mixed $data = null ]) : mixed
Parameters
- $name : string
- $data : mixed = null