当前位置:网站首页>Simple use of redis in laravel
Simple use of redis in laravel
2022-06-26 04:22:00 【Scholar and】
One : install
composer require predis/predis
Two : To configure (config/database.php)
'redis' => [
'client' => env('REDIS_CLIENT', 'predis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'predis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_DB', 0),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_CACHE_DB', 1),
],
],
3、 ... and :(.env file )
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
Four : Introduce classes
use Illuminate\Support\Facades\Redis;
5、 ... and : Use
//$key: Key value ( character string )
//$value: value ( character string ,json character string )
Redis::set($key, $value);// Set the cache
Redis::get($key);// Access to the cache
Redis::del($key);// Delete cache
边栏推荐
- What should I do if the 51 SCM board cannot find the device in keil
- Mysql8.0 configuring my SQL in INI file_ mode=NO_ AUTO_ CREATE_ User can start
- Tencent Interviewer: How did binder get its system services?
- Laravel access error could not be opened
- Sorting out the examination sites of the 13th Blue Bridge Cup single chip microcomputer objective questions
- SixTool-多功能多合一代挂助手源码
- Detailed explanation of widget construction process of fluent
- Microsoft prohibits Russian users from downloading and installing win10/11
- Which is the best embedded visual programming software? (introduction, evaluation and selection of visual programming platform) [scratch, mind+, mixly]
- 2021-01-31
猜你喜欢

线程同步之读写锁

Using jsup to extract images from interfaces

Double buffer technology asynchronous log system

Knowledge of SQL - database design, backup and restore

Spark - 一文搞懂 parquet
![[Qunhui] command line acme SH automatically apply for domain name certificate](/img/7b/8cb99ee0d74692ff6afd8513b02834.jpg)
[Qunhui] command line acme SH automatically apply for domain name certificate
![[QT] dialog box](/img/ca/e65a0c167a4509f7c6a241870f6a32.png)
[QT] dialog box

Mysql8.0 configuring my SQL in INI file_ mode=NO_ AUTO_ CREATE_ User can start

2021 year end summary

Resolve PHP is not an internal or external command
随机推荐
Verrouillage de lecture et d'écriture pour la synchronisation des fils
Oracle data pump table
Parse JSON interface and insert it into the database in batch
win10 系统打开的软件太小,如何变大(亲测有效)
Detailed explanation of globalkey of flutter
Performance test comparison between PHP framework jsnpp and thinkphp6
Gateway can not connect to tcp://127.0.0.1: Connection refused
mysql自帶的性能測試工具mysqlslap執行壓力測試
Implementation of seven classes of BlockingQueue interface
Alipay failed to verify the signature (sandbox test indicates fishing risk?) [original]
[QT] resource file import
Zhubo Huangyu: you can try these non-agricultural operation skills
Double buffer technology asynchronous log system
Ipvs0 network card of IPVS
VHDL design
【QT】资源文件导入
Navicat connects the pit of shardingsphere sub table and sub library plug-ins
PIP batch complete uninstall package
Simple personal summary of tp6 multi application deployment -- Part I [original]
Knowledge of SQL - database design, backup and restore