Cache Library



( ZN >= 1.0.0 )

This library is a class that performs operations such as retrieving, using, deleting. The caching library consists of 5 drives. Drivers are pre-defined for these drivers file. Other drivers are required to be installed in the system in order to use them.

 

# Configuration


File: Config / Storage.php
Cache
String $ driver = 'file' Driver information to be used for caching.
Options file , apc , apcu , memcache , wincache , redis
Array $ driverSettings = [] Connection setting sequence according to drive type.

 

# Cache Memory Drives


Net Ön tanımlıdır and does not require installation.
apc Requires installation in system. Apc Guide .
Memcache Requires installation in system. Memcache Guide .
WinCache Requires installation in system. Wincache Guide .
Redis Requires installation in system. Redis Guide .

 

# Methods


Mixed select ( String $ key , $ compressed = false )
Bool insert ( String $ key , Mixed $ var , Scalar $ time = 60 , Mixed $ compressed = false )
Bool delete ( String $ key )
Int increment ( String $ key , Int $ increment = 1 )
Int decrement ( String $ key , Int $ decrement = 1 )
Bool clean ()
Array info ( Mixed $ info )
Array getMetaData ( String $ key )
this driver ( String $ driver )
String code ( Callable $ function , Scalar $ time = 60 , String $ compress = 'gz' )
String view ( String $ file , Scalar $ time = 60 , String $ compress = 'gz' )
String file ( String $ file , Scalar $ time = 60 , String $ compress = 'gz' , $ type = 'something' )

 

# Insert ( ZN >= 1.0.0 )


Used to retrieve objects from the front memory.

Parameters

String $ key Data key.
Mixed $ data Data.
scaler $ time = 60 How many seconds will it hold. As of version 5.3.37 , time expressions can be written in this parameter.Örnek: 1 day , 10 month , 5 year
Mixed $ compressed = false Is compression done?
File Driver bz, gz, lzf, rar, zip, zlib
Other Driver true , false
return Bool

Use of

Cache::insert('example', 'Example Data', 120);

 

# Select ( ZN >= 1.0.0 )


It is used to reach the data received in the front memory. 

Parameters

String $ key Data key.
return Mixed

Use of

echo Cache::select('example');
Example Data

 

# Delete ( ZN> = 1.0.0 )


Used to delete an object from the foreground.

Parameters

String $ key Data key.
return Bool

Use of

Cache::delete('nesne');

 

# Clean ( ZN> = 1.0.0 )


It is used to clean the entire foreground data.

Parameters

void
return Bool

Use of

Cache::clean();

 

# Info ( ZN >= 1.0.0 )


It is used to retrieve data about the file that the whole foreground data is kept.

Parameters

String $ key Data key.
return Array

Use of

Cache::info();
basename    => string 'example' (length = 9 ) ,
size        => integer 77 (length = 2 ) ,
date        => integer 1472202339 (length = 10 ) ,
readable    => boolean true (length = 4 ) ,
writable    => Boolean true (length = 4 ) ,
executable => boolean false (length = 5 ) ,
permission => integer 33206 (length = 5 ) ,

 

# GetMetaData ( ZN >= 1.0.0 )


For information about the generated data.

Parameters

String $ key Data key.
return Array

Use of

Cache::getMetaData('example');
expire => integer 1472203618 (length = 10 ) ,
mtime   => integer 1472203498 (length = 10 ) ,

 

# Driver ( ZN> = 2.0.0 )


To use a different driver, this method writes the name of one of the current caching drivers as a parameter.

Parameters

String $ Driver Drive name.
return this

Use of

Cache::driver('apc')->insert('example', 'Example Data'); 
Cache::driver('memcache')->insert('nesne', 'Example Data');

 

# Code ( ZN >= 5.3.31 )


It is used to cache the output of code blocks.

Parameters

callable $ Function Codes to be cached.
scaler $ time = 60 Cache time.
String $ compress = 'gz' Compression driver.
return String

Use of

$cache = Cache::code(function()
{
    Import::view('contact');
}, '7 day');

echo $cache;

 

# View ( ZN >= 5.3.31 )


Used to cache view output.

Parameters

String $ Viewname Views / a file name of the directory.
scaler $ time = 60 Cache time.
String $ compress = 'gz' Compression driver.
return String

Use of

echo Cache::view('contact/main', '2 month');

Data Sending

For data transmission -> data () is optional.

echo Cache::data(['example' => 'Example Data'])->view('contact/main');

Refreshing the Data in the Front Page

To refresh or refresh the foreground data -> refresh () is optional.

echo Cache::refresh()->data(['example' => 'Example Data'])->view('contact/main');

 

# File ( ZN >= 5.3.31 )


Used to cache the output of any file.

Parameters

String $ Filename File name or path
scaler $ time = 60 Cache time.
String $ compress = 'gz' Compression driver.
return String

Use of

echo Cache::file(VIEWS_DIR . 'contact/main', '1 day');

Refresh and data sending operations are the same in this method.