Developers

David Rey Blanco

Download

Version 1.0

Project Links

SF web page

CVS

Other Links

WURFL project

Did you like the project?

Help us to keep developing features!

Support This Project

 

 

 

 

 

 


Site monitored by eXternalTest

WurflDBLayerCache

WurflDBLayerCache is a simple library for PHP Wurfl library acceleration, the library concept is based on a cache over a mysql database, this library will provide you a better performance versus the classical library, the figures I got in my tests were from 10x to 20x times faster than the classical library.

Other advantages of this library is the ease of installation and configuration, in fact an installation could take you just some minutes. It is only a cache for wurlf so there is no need of other components installation.

You can find more info about Wurfl at their web.

What do I need for the installation?

WurflDBLayerCache is compatible with PHP versions 4 and 5, as well as with mysql versions above 4.3 (I guess it could work with previous versions, but I have not tested it yet).

How can I use it?

It has a very simplified interface, let's say that the library will provide you a facade for Wurfl lib usage, for example this is an example of lib usage:

$facade = new WurflDBLayerCache();
$capabilities = $facade->getCapabilities($ua);

Where "$capabilities" is an object cointaining the capabilities of the handset, this object type is the same type wurfl deals with. In fact, this object has been serifalized and inserted into the DB and unserialized to be retrieved from DB.

And then, what I have to to to install the lib?

Just follow these three steps:

1st) Create the internal database for wurfl_cache, you only need to execute the mysql script from your phpmyadmin interface
(or in command line if you dare...), ths script is in the lib package and is called wurfl_db_cache_layer_db_cretion.sql.


2st) Install php files into your wurfl source folder, just copy WurflDBLayerCache.conf.php and WurflDBLayerCache.php.


3rd) Configure library, which consists in filling out the DB connection settings.

The following variables are referred to the DB connection:

define("WURFL_CACHE_DB_HOSTNAME","localhost"); // MSQL hostname
define("WURFL_CACHE_DB_USER","root"); // Database access username
define("WURFL_CACHE_DB_PASS",""); // Database access password
define("WURFL_CACHE_DB_DBNAME","wurfl_cache"); // Database name, by default 'wurfl_cache'

The time to live is the maximum time the cached records will live into de the database

define("WURFL_CACHE_TIME_TO_LIVE",3600*5); // Time to live of every record in the cache measured in seconds, 3600*5 = 5 hours

And by last, if you want to cleanup the cache every time you use the library, you can set up the following variable to true. Note that it is a more automatic way of calling the cache cleanup, but it implies more database usage and then you will loose a bit of performance.

The alternative to an automatic cleanup is to call it manually every five of 12 hours (or the period you will want to setup), you can program it by crontab or a similar tool.

define("WURFL_CACHE_CLEAN_UP_ON_EXECUTION",false); // Calls cleanup script on every execution not recommended

Troubleshooting and so on

Because it is the first release, I have no imagination enough to fill up this chapter, anyway for any question and so on you can send me an email at davidreyblanco@gmail.com

Enjoy the lib!