php dba cache
DESCRIPTION
The php-dba-cache uses the database (dbm-style) abstraction layer to cache/store your PHP objects, strings, integers or arrays. Even instances of SimpleXMLElement can be put to the cache. You dont have to matter about the size of the cache-file.It depends on the free space of your disk.TRANSCRIPT
PHP DBA CACHEStore data into dbm-style abstraction layer
04/13/2023 Gjero Krsteski
Introduction
uses the database (dbm-style) abstraction layer
store/ cache your objects, strings, integers or arrays
even instances of SimpleXMLElement
it depends on the free space of your disk
2
04/13/2023 Gjero Krsteski
Repository
GitHub gjerokrsteski/php-dba-cache
ZF-11073 Zend_Cache_Backend_Dba
ZF2-139 Zend\Cache\Storage\Adapter\Dba
3
04/13/2023 Gjero Krsteski
How it works
dbm-style abstraction layer wraps dba_* functions
Installation./configure
--enable-dba=shared
--with-[handler]
4
04/13/2023
DBA handlers
cdb Tiny Constant Database = r cdb_make Tiny Constant Database = w
db4 Oracle Berkeley DB 4 = rw qdbm Quick Database Manager = rw gdbm GNU Database Manager = rw inifile Ini File = rw flatfile default = rw
5Gjero Krsteski
04/13/2023 Gjero Krsteski
Cache options
open database insert, replace, get, delete record by key return metadata = expire + mtime get all keys
6
04/13/2023 Gjero Krsteski
Sweep options
is optional clean all entries clean expired entries flush the cache/storage file
7
04/13/2023 Gjero Krsteski
DB 4 with persistent connection
$cache = new Cache( '/your/path/to/cache-file.db4', 'db4');
$yorObject = new YourObjectYouWantToPutInCache();$yourObjectIdentifier = 'key:you:want';
// Check if your object is in the cache.// You also can ignore it, and let the CacheDba do it for you.if (false == $cache->has($yourObjectIdentifier)) { $cache->delete($yourObjectIdentifier);}
$cache->put($yourObjectIdentifier, $yorObject);
// Than somewhere at your project.$cache->get($yourObjectIdentifier);
8
04/13/2023 Gjero Krsteski
Sweep in action// For the garbage collection you can // create for example an cron-job starting once a day// or please use the DBA-Cache-Monitor GUI.$sweep = new Sweep($cache);
// clean all entries$sweep->all();
// or clean old entries – from now$sweep->old();
// or flush the whole storage!$sweep->flush();
9
04/13/2023 Gjero Krsteski
Cache Monitor
10
04/13/2023 Gjero Krsteski
Have fun with it…
Gjero Krsteski
Programmer, Consultant, Trainer
Homepage: krsteski.de
E-Mail: [email protected]
11