Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
R
Redis Page Cache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WP Plugins
Redis Page Cache
Commits
2da95e28
Commit
2da95e28
authored
Feb 26, 2014
by
Erick Hitter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only set database value when not zero, otherwise unnecessary `SELECT` calls result
parent
76bbe263
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
11 deletions
+19
-11
index-wp-redis.php
index-wp-redis.php
+16
-7
wp-redis-cache/wp-redis-cache.php
wp-redis-cache/wp-redis-cache.php
+3
-4
No files found.
index-wp-redis.php
View file @
2da95e28
...
...
@@ -196,9 +196,12 @@ function wp_redis_cache_connect_redis() {
}
$redis
=
new
Redis
();
$redis
->
connect
(
$wp_redis_cache_config
[
'redis_server'
],
$wp_redis_cache_config
[
'redis_port'
]
);
$redis
->
select
(
$wp_redis_cache_config
[
'redis_db'
]
);
// Default DB is 0, so only need to SELECT if other
if
(
$wp_redis_cache_config
[
'redis_db'
]
)
{
$redis
->
select
(
$wp_redis_cache_config
[
'redis_db'
]
);
}
// Fallback to predis5.2.php
}
else
{
if
(
$wp_redis_cache_config
[
'debug'
]
)
{
...
...
@@ -206,11 +209,17 @@ function wp_redis_cache_connect_redis() {
}
include_once
dirname
(
__FILE__
)
.
'/wp-content/plugins/wp-redis-cache/predis5.2.php'
;
//we need this to use Redis inside of PHP
$redis
=
new
Predis_Client
(
array
(
'host'
=>
$wp_redis_cache_config
[
'redis_server'
],
'port'
=>
$wp_redis_cache_config
[
'redis_port'
],
'database'
=>
$wp_redis_cache_config
[
'redis_db'
],
)
);
$redis
=
array
(
'host'
=>
$wp_redis_cache_config
[
'redis_server'
],
'port'
=>
$wp_redis_cache_config
[
'redis_port'
],
);
// Default DB is 0, so only need to SELECT if other
if
(
$wp_redis_cache_config
[
'redis_db'
]
)
{
$redis
[
'database'
]
=
$wp_redis_cache_config
[
'redis_db'
];
}
$redis
=
new
Predis_Client
(
$redis
);
}
return
$redis
;
...
...
wp-redis-cache/wp-redis-cache.php
View file @
2da95e28
...
...
@@ -134,17 +134,16 @@ class WP_Redis_Cache {
$redis_settings
=
array
(
'host'
=>
'127.0.0.1'
,
'port'
=>
6379
,
'database'
=>
0
,
);
// Override default connection settings with global values, when present
if
(
defined
(
'WP_REDIS_CACHE_REDIS_HOST'
)
)
{
if
(
defined
(
'WP_REDIS_CACHE_REDIS_HOST'
)
&&
WP_REDIS_CACHE_REDIS_HOST
)
{
$redis_settings
[
'host'
]
=
WP_REDIS_CACHE_REDIS_HOST
;
}
if
(
defined
(
'WP_REDIS_CACHE_REDIS_PORT'
)
)
{
if
(
defined
(
'WP_REDIS_CACHE_REDIS_PORT'
)
&&
WP_REDIS_CACHE_REDIS_PORT
)
{
$redis_settings
[
'port'
]
=
WP_REDIS_CACHE_REDIS_PORT
;
}
if
(
defined
(
'WP_REDIS_CACHE_REDIS_DB'
)
)
{
if
(
defined
(
'WP_REDIS_CACHE_REDIS_DB'
)
&&
WP_REDIS_CACHE_REDIS_DB
)
{
$redis_settings
[
'database'
]
=
WP_REDIS_CACHE_REDIS_DB
;
}
...
...
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