php dba cache

11

Click here to load reader

Upload: gjero-krsteski

Post on 23-Jun-2015

1.181 views

Category:

Technology


0 download

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

Page 1: Php dba cache

PHP DBA CACHEStore data into dbm-style abstraction layer

Page 2: Php dba cache

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

Page 3: Php dba cache

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

Page 4: Php dba cache

04/13/2023 Gjero Krsteski

How it works

dbm-style abstraction layer wraps dba_* functions

Installation./configure

--enable-dba=shared

--with-[handler]

4

Page 5: Php dba cache

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

Page 6: Php dba cache

04/13/2023 Gjero Krsteski

Cache options

open database insert, replace, get, delete record by key return metadata = expire + mtime get all keys

6

Page 7: Php dba cache

04/13/2023 Gjero Krsteski

Sweep options

is optional clean all entries clean expired entries flush the cache/storage file

7

Page 8: Php dba cache

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

Page 9: Php dba cache

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

Page 10: Php dba cache

04/13/2023 Gjero Krsteski

Cache Monitor

10

Page 11: Php dba cache

04/13/2023 Gjero Krsteski

Have fun with it…

Gjero Krsteski

Programmer, Consultant, Trainer

Homepage: krsteski.de

E-Mail: [email protected]

11