Cache | Flextype

Cache

Core Concepts

Flextype caching system is really smart and efficient! We are using established and well-respected Doctrine Cache library. This means that Flextype supports any caching mechanism that Doctrine Cache supports and our own PhpArrayFile driver which stores the data in a native PHP array.

By default, Flextype comes preconfigured to use the auto setting. This will try APC, then WinCache, then XCache, and lastly PhpArrayFile. You can, of course, explicitly configure the cache in your project/config/flextype/settings.yaml file, which could make things ever so slightly faster.

Methods

Name Description
getCacheDriver() Get Active Cache Driver
driver() Returns a driver object
getKey() Get cache key.
contains() Returns a boolean state of whether or not the item exists in the cache based on id key.
fetch() Fetches an item from the cache.
fetchMultiple() Fetches multiple items from the cache.
delete() Delete specific item from the cache.
deleteMultiple() Delete multiple item from the cache.
deleteAll() Deletes all cache items.
flushAll() Flushes all cache items.
purge() Purge specific cache directory.
purgeAll() Purge all cache directories.
save() Puts data into the cache.
saveMultiple() Puts multiple data into the cache.
setLifetime() Set the cache lifetime.
getLifetime() Retrieve the cache lifetime (in seconds)
getStats() Retrieves cached information from the data store.

Methods Details

getCacheDriver()

Get Active Cache Driver.

Examples

$cache_driver = flextype('cache')->getCacheDriver();
driver()

Returns a driver object

Examples

$driver = flextype('cache')->driver();
getKey()

Get cache key.

Examples

$cache_key = flextype('cache')->getKey();
contains()

Returns a boolean state of whether or not the item exists in the cache based on id key.

Examples

Check is posts are exists in the cache then fetch them.

if (flextype('cache')->contains('posts')) {
    $posts = flextype('cache')->fetch('posts');
}
fetch()

Fetches an item from the cache.

Examples

Fetch posts from cache.

$posts = flextype('cache')->fetch('posts');
fetchMultiple()

Fetches multiple items from the cache.

Examples

Fetch posts and comments from the cache.

$data = flextype('cache')->fetchMultiple(['posts', 'comments']);
delete()

Delete specific item from the cache.

Examples

Delete posts from the cache.

flextype('cache')->delete('posts');
deleteMultiple()

Delete multiple item from the cache.

Examples

Delete posts and comments from the cache.

flextype('cache')->deleteMultiple(['posts', 'comments']);
deleteAll()

Deletes all cache items.

Examples

flextype('cache')->deleteAll();
flushAll()

Flushes all cache items.

Examples

flextype('cache')->flushAll();
purge()

Purge specific cache directory.

Examples

Clear doctrine cache.

flextype('cache')->purge('doctrine');
purgeAll()

Purge all cache directories.

Examples

flextype('cache')->purgeAll();
save()

Puts data into the cache.

Examples

flextype('cache')->save('posts', $posts);
saveMultiple()

Puts multiple data into the cache.

Examples

flextype('cache')->saveMultiple(['posts' => $posts, 'comments' => $comments]);
setLifetime()

Set the cache lifetime.

Examples

flextype('cache')->setLifetime(300);
getLifetime()

Retrieve the cache lifetime (in seconds)

Examples

$lifetime = flextype('cache')->getLifetime();
getStats()

Retrieves cached information from the data store.

Examples

$stats = flextype('cache')->getStats();
Language: en, ru