- skip to content

# Database Abstraction Layer

### User Tools

- Login

### Site Tools

- Recent changes
- Media Manager
- Sitemap

### Sidebar

##### Resources

- Reference Manual
- User Guide
- The Data Dictionary
- ADOdb-xmlschema
- ADOdb Active Record
- Performance Monitoring
- Date/Time Library
- Session Management Library
- Unsupported Addons
- Coding Standards

##### Supported Databases

- Access
- ADO
- CSV
- Firebird
- Frontbase
- IBM DB2
- Informix
- Interbase
- LDAP
- Microsoft SQL Server
- MySQL
- Netezza
- ODBC
- ODBTP
- Oracle
- PDO
- Postgresql
- SAP ADS
- SAP ASE
- SAP Maxdb
- SAP Sqlanywhere
- Sqlite
- Sybase
- Plain Text
- Visual Foxpro

##### Other

- Feature Comparison Matrix
- Connection Matrix
- Include File Guide

v5:userguide:memcached

# Memcached Setup

There are 2 pear modules for connection to a Memcached server, the older PEAR Memcache library and the newer PEAR Memcached library.

- Windows support is only available for the older Memcache library.
- ADOdb has only been tested against the older library

## Description

This section describes connection to an already configured Memcache server. Information about installation and configuration of Memcached servers can be found here.

## The Memcache Library

## Usage

    $db = NewADOConnection($driver='mysqli');
    /*
    * Enable memcache
    */
    $db->memCache = true;
    /*
    * Add one or more servers, for use in distributed systems
    */
    $db->memCacheHost = array('192.168.0.78', '192.168.0.79', '192.168.0.80');
    /*
    * Optionally add the server port if it differs from the default
    */
    $db->memCachePort = 11211;
    /*
    * Use 'true' to store the item compressed (uses zlib)
    */
    $db->memCacheCompress = false;

    /*
    * We connect to the database, not the memcache server
    */
    $db->Connect('localhost','mysql-user','mysql-password','employees');

    /*
    * look for a cached query with a life of 2400 seconds
    */
    $sql = 'SELECT code,description FROM xref_table';
    $db->cacheExecute(2400,$sql);

## Using Debug Mode

The size of query results that can be cached by the memcached server is limited by server configuration. The default is quite small. If the query is too large, and debugging is enabled, then an error is displayed.

    3849805e4e026b9e7c485999a24a95c6 cache failure: Item with such key doesn't exists on the memcached server.
    (this is a notice and not an error)
    -----<hr>

    (mysqli): SELECT * FROM employees

    -----<hr>
    Notice: MemcachePool::set(): Server 192.168.0.78 (tcp 11211, udp 0) failed with:
    SERVER_ERROR object too large for cache
    (3) in C:\dev\github\mssqlnative-fixes\adodb-memcache.lib.inc.php on line 94
    Failed to save data at the memcached server!

    Cache write error

    PHP Notice:  MemcachePool::set(): Server 192.168.0.78 (tcp 11211, udp 0) failed with:
    SERVER_ERROR object too large for cache (3)
    in C:\dev\github\mssqlnative-fixes\adodb-memcache.lib.inc.php on line 94

ADOdb currently has no mechanism for splitting large queries into smaller chunks.

[memcached, cache]
v5/userguide/memcached.txt · Last modified: 2016/01/16 18:39 by mnewnham

### Page Tools

- Show pagesource
- Old revisions
- Backlinks
- Rename Page
- Back to top