Home > Backend Development > PHP Tutorial > How to install redis in thinkphp

How to install redis in thinkphp

WBOY
Release: 2016-07-06 13:53:06
Original
1820 people have browsed it

How to install redis in thinkphp
Although there is S function
but how to install it

Reply content:

How to install redis in thinkphp
Although there is S function
but how to install it

ThinkPHP has a redis class, so you don’t need to write another one.

1, install redis and start redis-server
2, install phpredis extension, https://github.com/phpredis/phpredis
3, set the cache type in the tp configuration file to DATA_CACHE_TYPE => ; 'Redis'

There are several parameter items

<code>$options = array_merge(array(
            'host'       => C('REDIS_HOST') ?: '127.0.0.1',
            'port'       => C('REDIS_PORT') ?: 6379,
            'password'   => C('REDIS_PASSWORD') ?: '',
            'timeout'    => C('DATA_CACHE_TIMEOUT') ?: false,
            'persistent' => false,
        ), $options);</code>
Copy after login

It should be said that PHP loads the redis extension, and then you can operate redis in the corresponding controller file

php and redis have nothing to do with each other
I don’t know what the question means
thinkphp How to use redis? There must be a corresponding class library
a c extension https://github.com/phpredis/phpredis

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template