Showing posts with label cache. Show all posts
Showing posts with label cache. Show all posts

Monday 16 February 2015

Install latest Redis cache

Redis is an open source advanced key-value cache. It is high performance and often compared to memcached.

This post we look into how to install latest Redis cache onto (say) Fedora 21. It is quite simple, and lets start:

Goto http://redis.io/download, and download latest version using wget.
wget http://download.redis.io/releases/redis-2.8.19.tar.gz
untar/unzip the package
tar -xzvf redis-2.8.19.tar.gz
compile the bundle
cd redis-2.8.19
make
It is good to do a "make test" to test the functionality on your system. For this test you need tcl.

If you don't have tcl, install it by:
yum install tcl
Run make test:
make test
If functionality test passed it will show:
\o/ All tests passed without errors!
Lets install the excutables into /usr/local/bin/.
make install
For Fedora systemctl system, lets create a redis service script.
vi /usr/lib/systemd/system/redis.service

[Unit]
Description=Redis persistent key-value database
After=network.target

[Service]
ExecStart=/usr/local/bin/redis-server /etc/redis.conf --daemonize no
ExecStop=/usr/local/bin/redis-shutdown
User=redis
Group=redis

[Install]
WantedBy=multi-user.target
Move sample redis.conf to /etc.
cp /root/download/redis-2.8.19/redis.conf /etc/redis.conf
Create redis-shutdown script.
vi /usr/local/bin/redis-shutdown
#!/bin/bash
#
# Wrapper to close properly redis and sentinel
test x"$REDIS_DEBUG" != x && set -x

REDIS_CLI=/usr/local/bin/redis-cli

# Retrieve service name
SERVICE_NAME="$1"
if [ -z "$SERVICE_NAME" ]; then
   SERVICE_NAME=redis
fi

# Get the proper config file based on service name
CONFIG_FILE="/etc/$SERVICE_NAME.conf"

# Use awk to retrieve port from config file
PORT=`awk '/^[[:blank:]]*port/ { print $2 }' $CONFIG_FILE`

# Just in case, use default port
if [ "$SERVICE_NAME" = redis ]; then
    PORT=${PORT:-6379}
else
    PORT=${PORT:-26739}
fi

# shutdown the service properly
$REDIS_CLI -p $PORT SHUTDOWN NOSAVE
Enable and start redis service.
systemctl enable redis.service
systemctl start redis.service
Lets try the redis-cli. Set a key and get a key:
[root@fc21 temp]# redis-cli
127.0.0.1:6379> get key1
(nil)
127.0.0.1:6379> set key1 value1
OK
127.0.0.1:6379> get key1
"value1"

Thursday 11 April 2013

Install APC (php) on Fedora 18

The Alternative PHP Cache (APC) is a bytecode optimization opcode cache for PHP. This free cache leads to faster runtime execution as it stores the final, compiled result in shared memory. To install APC, you can setup using YUM.
[root@localhost ~]# yum install php-pecl-apc
Using YUM method, it will create /etc/php.d/apc.ini , enabling apc extension module "extension = apc.so". If apc.ini is not found, you can insert "extension = apc.so" into php.ini. After apache restart(service httpd restart), you will see apc enabled in phpinfo.php. APC,cache,phpinfo

Wednesday 10 April 2013

How to setup MySQL Query Cache

The query cache stores the text of a SELECT statement together with the corresponding result that was sent to the client. If an identical statement is received later, the server retrieves the results from the query cache rather than parsing and executing the statement again.

By default query cache size is 0, which is deactivated. To enable it, you can set the query_cache_size to 1000000.

mysql> SET GLOBAL query_cache_size = 1000000;
Query OK, 0 rows affected (0.04 sec) 

mysql> SHOW VARIABLES LIKE 'query_cache_size';
+------------------+--------+ 
|Variable_name     | Value  | 
+------------------+--------+ 
| query_cache_size | 999424 | 
+------------------+--------+ 
1 row in set (0.00 sec)

search iomeweekly