Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
Redis: Use Redis DB-Index when computing the SystemCache lookup key (#…
Browse files Browse the repository at this point in the history
…1776)

Fixes #1771
  • Loading branch information
oschaaf authored Jun 28, 2018
1 parent 337f262 commit b4bf44c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
4 changes: 2 additions & 2 deletions install/debug.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER application/xhtml+xml
#REDIS
#REDIS # Do testing using redis instead of file cache
#REDIS ModPagespeedRedisServer localhost:@@REDIS_PORT@@
#REDIS ModPagespeedRedisDatabaseIndex 2
#EXTCACHE
# If X-PSA-Blocking-Rewrite request header is present and its value matches the
# value of ModPagespeedBlockingRewriteKey below, the response will be fully
Expand Down Expand Up @@ -534,14 +535,14 @@ NameVirtualHost localhost:@@APACHE_SECONDARY_PORT@@
ModPagespeed on
ModPagespeedFileCachePath "@@MOD_PAGESPEED_CACHE@@_secondary"
ModPagespeedCompressMetadataCache false

ModPagespeedMapProxyDomain secondary.example.com/gstatic_images \
http://www.gstatic.com/psa/static

# This is the same external cache instance as the root configuration,
# but with a different file-cache path.
#MEMCACHED ModPagespeedMemcachedServers localhost:@@MEMCACHED_PORT@@
#REDIS ModPagespeedRedisServer localhost:@@REDIS_PORT@@
#REDIS ModPagespeedRedisDatabaseIndex 3

ModPagespeedCacheFlushFilename cache.flush
# If you uncomment this, the test will fail, proving we can disable
Expand Down Expand Up @@ -1368,7 +1369,6 @@ ModPagespeedCreateSharedMemoryMetadataCache "@@MOD_PAGESPEED_CACHE@@_with_shm" 8
ModPagespeedFileCachePath "@@MOD_PAGESPEED_CACHE@@_lrud_lrum"
#MEMCACHED ModPagespeedMemcachedServers localhost:@@MEMCACHED_PORT@@
#REDIS ModPagespeedRedisServer localhost:@@REDIS_PORT@@

ModPagespeedLRUCacheKbPerProcess 1024
ModPagespeedLRUCacheByteLimit 2000
ModPagespeedEnableFilters rewrite_images
Expand Down
1 change: 1 addition & 0 deletions pagespeed/system/system_caches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ SystemCaches::ExternalCacheInterfaces SystemCaches::NewExternalCache(
if (use_redis) {
spec_signature =
StrCat("r;", config->redis_server().ToString(), ";",
IntegerToString(config->redis_database_index()), ";",
IntegerToString(config->redis_reconnection_delay_ms()), ";",
IntegerToString(config->redis_timeout_us()));
} else if (use_memcached) {
Expand Down
7 changes: 7 additions & 0 deletions pagespeed/system/system_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,10 @@ run_test long_url_handling
run_test controller_process_handling
run_test strip_subresources
run_test protocol_relative_urls

# TODO(oschaaf): REDIS_PORT seems to be set when
# redis actually isn't used in the system tests.
# Fix that, and enable this test.
#if [ "${REDIS_PORT:-0}" -ne 0 ]; then
# run_test redis
#fi
30 changes: 30 additions & 0 deletions pagespeed/system/system_tests/redis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
start_test Redis database index respected

# the default redis DB is not used, dbsize should equal 0
OUT=$(echo -e 'DBSIZE' | redis-cli -p "${REDIS_PORT}")
check [ "0" -eq "$OUT" ]
# db #2 is primary, and should be non-0 at this point
OUT=$(echo -e 'select 2 \n DBSIZE' | redis-cli -p "${REDIS_PORT}")
check_from "$OUT" grep -Pzo 'OK\n[1-9]'

# TODO(oschaaf): attempts to get the redis tests to run with the
# secondary host available failed. The test above at least makes
# sure that the setting that specifies db index 3 isn't used in
# the primary host which uses db index 2.
# db #3 is secondary, and should be non-0 at this point
#RES=$(echo -e 'select 3 \n DBSIZE' | redis-cli -p "${REDIS_PORT}")
#check_from "$OUT" grep -Pzo 'OK\n[1-9]'

0 comments on commit b4bf44c

Please sign in to comment.