Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
M
memcache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
memcache
Commits
cd5df57a
Commit
cd5df57a
authored
Apr 17, 2013
by
Phizes
Committed by
Jeremy
Apr 17, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1690130
by Phizes: Support sockets with PECL memcached extension.
parent
f173ea71
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
18 deletions
+33
-18
README.txt
README.txt
+15
-8
dmemcache.inc
dmemcache.inc
+18
-10
No files found.
README.txt
View file @
cd5df57a
...
...
@@ -55,7 +55,8 @@ pattern:
'memcache_servers' => array(
host1:port => cluster,
host2:port => cluster,
hostN:port => cluster
hostN:port => cluster,
'unix:///path/to/socket' => cluster
)
'memcache_bins' => array(bin1 => cluster, bin2 => cluster, binN => cluster)
...
...
@@ -74,20 +75,26 @@ The bin/cluster/server model can be described as follows:
- The default cluster is 'default'.
Here is a simple setup that has two memcached instances, both running on
localhost. The 11212 instance belongs to the 'pages' cluster and the table
cache_page is mapped to the 'pages' cluster. Thus everything that gets cached,
with the exception of the page cache (cache_page), will be put into 'default',
or the 11211 instance. The page cache will be in 11212.
Here is a simple setup that has three memcached instances, two running on
localhost, and one on a Unix socket. The 11212 instance belongs to the 'pages'
cluster and the table cache_page is mapped to the 'pages' cluster. The Unix
socket instance belongs to the 'blocks' cluster, and the table cache_block is
mapped to the 'blocks' cluster. Thus everything that gets cached, with the
exception of the page cache (cache_page) and block cache (cache_block), will be
put into 'default', or the 11211 instance. The page cache will be in 11212, and
the block cache in the Unix socket instance. Note that no port is specified for
the socket.
$conf = array(
...
// Important to define a default cluster in both the servers
// and in the bins. This links them together.
'memcache_servers' => array('localhost:11211' => 'default',
'localhost:11212' => 'pages'),
'localhost:11212' => 'pages',
'unix:///path/to/socket' => 'blocks'),
'memcache_bins' => array('cache' => 'default',
'cache_page' => 'pages'),
'cache_page' => 'pages',
'cache_block' => 'blocks'),
);
Here is an example configuration that has two clusters, 'default' and
...
...
dmemcache.inc
View file @
cd5df57a
...
...
@@ -365,16 +365,15 @@ function dmemcache_object($bin = NULL, $flush = FALSE) {
if
(
$c
==
$cluster
&&
!
isset
(
$failed_connection_cache
[
$s
]))
{
list
(
$host
,
$port
)
=
explode
(
':'
,
$s
);
// Support unix sockets in the format 'unix:///path/to/socket'.
if
(
$host
==
'unix'
)
{
// When using unix sockets use the full path for $host.
$host
=
$s
;
// Port is always 0 for unix sockets.
$port
=
0
;
}
// Using the Memcache PECL extension.
if
(
$memcache
instanceof
Memcache
)
{
// Support unix sockets in the format 'unix:///path/to/socket'.
if
(
$host
==
'unix'
)
{
// When using unix sockets with Memcache use the full path for $host.
$host
=
$s
;
// Port is always 0 for unix sockets.
$port
=
0
;
}
// When using the PECL memcache extension, we must use ->(p)connect
// for the first connection.
if
(
!
$init
)
{
...
...
@@ -398,8 +397,17 @@ function dmemcache_object($bin = NULL, $flush = FALSE) {
$memcache
->
addServer
(
$host
,
$port
,
$memcache_persistent
);
}
}
else
if
(
$memcache
->
addServer
(
$host
,
$port
)
&&
!
$init
)
{
$init
=
TRUE
;
else
{
// Support unix sockets in the format 'unix:///path/to/socket'.
if
(
$host
==
'unix'
)
{
// Memcached expects just the path to the socket without the protocol
$host
=
substr
(
$s
,
7
);
// Port is always 0 for unix sockets.
$port
=
0
;
}
if
(
$memcache
->
addServer
(
$host
,
$port
)
&&
!
$init
)
{
$init
=
TRUE
;
}
}
if
(
!
$init
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment