CacheFlush

Flush the cache, if no parameter specified it will flush all the cache.

Parameters

CacheFlush(sql or group, $key=null)
sql or group:The query to flush or the group name.
$key:The custom key assigned to the query.

To flush / empty all the cache just call the CacheFlush with no parameteres, example:

$db->CacheFlush();

Examples

Flush a query:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<?php

require_once 'dalmp.php';

$user = getenv('MYSQL_USER') ?: 'root';
$password = getenv('MYSQL_PASS') ?: '';

$DSN = "utf8://$user:$password".'@localhost/dalmp?redis:127.0.0.1:6379';

$db = new DALMP\Database($DSN);

$db->FetchMode('ASSOC');

$rs = $db->CacheGetAll(300, 'SELECT * FROM City');

// To flush the query
$db->CacheFlush('SELECT * FROM City');

Flush a query with a custom key:

1
2
3
4
5
<?php
...
$rs = $db->CacheGetAll(300, 'SELECT * FROM City', 'my_custom_key');

$db->CacheFlush('SELECT * FROM City', 'my_custom_key');

Flushing a chached group:

1
2
3
4
5
6
7
<?php
...
$rs = $db->CachePGetAll('SELECT * FROM Country WHERE Population <= ?', 100000, 'group:B');
$rs = $db->CachePGetAll(86400, 'SELECT * FROM Country WHERE Continent = ?', 'Europe', 'group:B');

// To flush all the group
$db->CacheFlush('group:B');

A great amount of time has been spent creating, crafting and maintaining this software, please consider donating.

Donating helps ensure continued support, development and availability.

dalmp


comments powered by Disqus