Jump to content

Redis key-value store cache + IPB 3.3.x / 3.4.x


Recommended Posts

Posted

With the IPS4 beta code and documentation about phpredis I created a Redis class for Invision Board 3.3.x and 3.4.x

With some simple file modifications you can make this easily work on your own webserver to make use of the very fast Redis key-value store.

Please notice you first have to install Redis and the PHP Redis module on your server. It seems Redis only needs a few MB of memory to store the date. This will be probably more with IPS4, because IPS has many caching improvements.

 

1. Download the attachment ( RedisCache.zip ) and upload classCacheRedis.php to the ips_kernel directory

 

2. Add the following code to ipsRegistry.php in admin/sources/base above the Eaccelerator... code:

            //--------------------------------
			// Redis...
			//--------------------------------

			if( ipsRegistry::$settings['use_redis'] == 1 )
			{
				require( IPS_KERNEL_PATH.'interfaces/interfaceCache.php' );/*noLibHook*/
				require( IPS_KERNEL_PATH.'classCacheRedis.php' );/*noLibHook*/
				self::$cacheLib = new classCacheRedis( ipsRegistry::$settings['board_url'] );
			}

3. Change in the ipsRegistry.php file the if at Eaccelerator to else if

You should get the following:

		else if( function_exists('eaccelerator_get') AND ipsRegistry::$settings['use_eaccelerator'] == 1 )

4. Add the following line to conf_global.php:

$INFO['use_redis'] = '1';

5. Happy fast IPB Redis caching!

# Server
redis_version:2.8.x
redis_mode:standalone
arch_bits:64
multiplexing_api:epoll
tcp_port:6379
uptime_in_seconds:69656
uptime_in_days:0
hz:10
lru_clock:9787554
config_file:/etc/redis.conf

# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:3796000
used_memory_human:3.62M
used_memory_rss:8122368
used_memory_peak:4241256
used_memory_peak_human:4.04M
used_memory_lua:35840
mem_fragmentation_ratio:2.14
mem_allocator:jemalloc-3.6.0

# Stats
total_connections_received:81895
total_commands_processed:3030017
instantaneous_ops_per_sec:69
total_net_input_bytes:186595137
total_net_output_bytes:86289079947
instantaneous_input_kbps:3.52
instantaneous_output_kbps:1929.71
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:461
evicted_keys:0
keyspace_hits:2986047
keyspace_misses:20373

Notice: I only tested this on one server. Use of the code is at your own risk!

 

Please share your code suggestions and results! :)

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...