File: config.inc

package info (click to toggle)
php-memcached 3.1.5%2B2.2.0-5%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,952 kB
  • sloc: ansic: 9,587; xml: 1,318; php: 385; pascal: 87; sh: 12; makefile: 5
file content (73 lines) | stat: -rw-r--r-- 1,958 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php

if (file_exists (dirname (__FILE__) . '/config.inc.local')) {
	include dirname (__FILE__) . '/config.inc.local';
}
else {
	define ("MEMC_SERVER_HOST", "127.0.0.1");
	define ("MEMC_SERVER_PORT", 11211);

	//define ("MEMC_SASL_SERVER_HOST", "127.0.0.1");
	//define ("MEMC_SASL_SERVER_PORT", 11212);

	//define ('MEMC_SASL_USER', 'memcached');
	//define ('MEMC_SASL_PASS', 'test');
}

function memc_create_instance ($host, $port, array $opts = array (), $persistent_id = null)
{
	$memcached = new Memcached($persistent_id);
	if ($memcached->setOptions ($opts) == false)
		echo "Failed to set options" . PHP_EOL;

	$memcached->addServer($host, $port);
	if ($memcached->flush() === false) {
		return NULL;
	}
	return $memcached;
}

function memc_get_instance (array $opts = array (), $persistent_id = null)
{
	return memc_create_instance(MEMC_SERVER_HOST, MEMC_SERVER_PORT, $opts, $persistent_id);
}

function memc_get_sasl_instance (array $opts = array (), $persistent_id = null)
{
	return memc_create_instance(MEMC_SASL_SERVER_HOST, MEMC_SASL_SERVER_PORT, $opts, $persistent_id);
}

function memc_run_test ($test_function, $options = array ())
{
	foreach ($options as $option_set) {
		$memc = memc_get_instance ($option_set ['options']);
		$test_function ($memc, $option_set);
	}
	echo "TEST DONE" . PHP_EOL;
}

function memc_create_combinations ($name, $serializer, $ignore_object_type = false)
{
	return array (
			array (
				'title' => "$name serializer, ascii protocol",
				'options' => array (
					Memcached::OPT_SERIALIZER => $serializer
				),
				'ignore_object_type' => $ignore_object_type
			),
			array (
				'title' => "$name serializer, binary protocol",
				'options' => array (
					Memcached::OPT_BINARY_PROTOCOL => true,
					Memcached::OPT_SERIALIZER => $serializer
				),
				'ignore_object_type' => $ignore_object_type
			),
	);
}

function memc_get_version($memc) {
	$version = $memc->getVersion();
	return array_pop($version);
}