Oracle 5.0 Reference Manual page 1394

Table of Contents

Advertisement

appears in the instance list, therefore increasing the likelihood of the instance being chosen over other
instances. To set the weight, set the value of the
The functions for setting and retrieving information are identical to the generic functional interface
offered by memcached, as shown in this table:
PECL
Function
memcache
get()
set()
add()
replace()
delete()
increment()
decrement()
A full example of the PECL
Sakila database when the user provides a film name. The data stored into the
recorded as a
mysqli
<?php
$memc = new Memcache;
$memc->addServer('localhost','11211');
if(empty($_POST['film'])) {
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Memcache Lookup</title>
</head>
<body>
<form method="post">
<p><b>Film</b>: <input type="text" size="20" name="film"></p>
<input type="submit">
</form>
<hr/>
<?php
} else {
echo "Loading data...\n";
$film
= htmlspecialchars($_POST['film'], ENT_QUOTES, 'UTF-8');
$mfilms = $memc->get($film);
if ($mfilms) {
printf("<p>Film data for %s loaded from memcache</p>", $mfilms['title']);
foreach (array_keys($mfilms) as $key) {
printf("<p><b>%s</b>: %s</p>", $key, $mfilms[$key]);
}
} else {
$mysqli = mysqli('localhost','sakila','password','sakila');
if (mysqli_connect_error()) {
sprintf("Database error: (%d) %s", mysqli_connect_errno(), mysqli_connect_error());
exit;
}
$sql = sprintf('SELECT * FROM film WHERE title="%s"', $mysqli->real_escape_string($film));
Developing a
memcached
interface is provided below. The code loads film data from the
memcache
result row, and the API automatically serializes the information for you.
1374
Application
argument to more than one.
$weight
Generic Function
Generic get().
Generic set().
Generic add().
Generic replace().
Generic delete().
Generic incr().
Generic decr().
instance is
memcached

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents