6

This is a tutorial post .

environment :

Fastadmin the latest version

tp5

pagoda

1. First, install the panel in the pagoda , find redis, Click Install .

2. Installation completed redis after , Click Settings , Set passwords

3.php Environmental installation redis extend

install redis Extended , Must be used by the deployed website php edition . Make no mistake .

4. In the root directory extend Create file in folder  RedisPackage.php
<?php //
+---------------------------------------------------------------------- // |
Description: redis Cache encapsulation use //
+---------------------------------------------------------------------- // |
Author: phpAndy <383916522@qq.com> //
+---------------------------------------------------------------------- class
RedisPackage { protected static $handler = null; protected $options = [ 'host'
=> '127.0.0.1', 'port' => 6379, 'password' => ' This is what you set up before redis password ', 'select' =>
0, 'timeout' => 20,// Closing time 0: On behalf of not closing 'expire' => 0, 'persistent' => false,
'prefix' => '', ]; public function __construct($options = []) { if
(!extension_loaded('redis')) { // Judge whether there is extension ( If your apache no reids The extension will throw this exception ) throw new
\BadFunctionCallException('not support: redis'); } if (!empty($options)) {
$this->options = array_merge($this->options, $options); } $func =
$this->options['persistent'] ? 'pconnect' : 'connect'; // Determine whether the connection is long self::$handler
= new \Redis; self::$handler->$func($this->options['host'],
$this->options['port'], $this->options['timeout']); if ('' !=
$this->options['password']) { self::$handler->auth($this->options['password']);
} if (0 != $this->options['select']) {
self::$handler->select($this->options['select']); } } /** * Write cache * @param
string $key Key name * @param string $value Key value * @param int $exprie Expiration time 0: Never expire *
@return bool */ public static function set($key, $value, $exprie = 0) { if
($exprie == 0) { $set = self::$handler->set($key, $value); } else { $set =
self::$handler->setex($key, $exprie, $value); } return $set; } /** * Read cache *
@param string $key Key value * @return mixed */ public static function get($key) {
$fun = is_array($key) ? 'Mget' : 'get'; return self::$handler->{$fun}($key); }
/** * Get value length * @param string $key * @return int */ public static function
lLen($key) { return self::$handler->lLen($key); } /** * Insert one or more values into the list header * @param
$key * @param $value * @return int */ public static function LPush($key,
$value, $value2 = null, $valueN = null) { return self::$handler->lPush($key,
$value, $value2, $valueN); } /** * Move out and get the first element of the list * @param string $key * @return
string */ public static function lPop($key) { return
self::$handler->lPop($key); } }

this php The document was written by a big man , I can't find it for a while .

Remember there's a setting on it redis Where the password is , Change it to your own .

Remember there's a setting on it redis Where the password is , Change it to your own .

Remember there's a setting on it redis Where the password is , Change it to your own .

5. To use Redis of Controller in , Import file
import('RedisPackage', EXTEND_PATH);

6. use
# set up \RedisPackage::set(' To set key',' This is value'); # obtain $key =
\RedisPackage::get(' Set key'));

thus , Pagoda panel +thinkphp environment use redis End of tutorial .

Technology
©2019-2020 Toolsou All rights reserved,
C++ of string of compare usage MySQL Basics Commonly used sentence ( Add / delete / modify query )C Language of a Gobang game implementation QT5.9 Use of learning notes QSqlQuery Method of Qt Getting Started tutorial 【 Basic controls 】QCalendarWidget calendar control java Polymorphic array of web Front end signature plug-in _signature_pad Plug in implements electronic signature function centos7 install RabbitMqspringboot use redis Experiment 4 Automated test tools - software test