@@ -0,0 +1,34 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | 缓存设置
+return [
+ // 默认缓存驱动
+ 'default' => env('cache.driver', 'file'),
+ // 缓存连接方式配置
+ 'stores' => [
+ 'file' => [
+ // 驱动方式
+ 'type' => 'File',
+ // 缓存保存目录
+ 'path' => '',
+ // 缓存前缀
+ 'prefix' => '',
+ // 缓存有效期 0表示永久缓存
+ 'expire' => 0,
+ // 缓存标签前缀
+ 'tag_prefix' => 'tag:',
+ // 序列化机制 例如 ['serialize', 'unserialize']
+ 'serialize' => [],
+ ],
+ // 更多的缓存连接
+ 'redis' => [
+ 'host' => '127.0.0.1',
+ 'port' => 6379,
+ 'type' => 'redis',
+ ]
+];
@@ -0,0 +1,12 @@
+/**
+ * Created by PhpStorm
+ * User: 林志杰
+ * Email: [email protected]
+ * Time: 2020/1/12 20:48
+ */
+ 'code_pre' => 'mall_code_pre_',
+ 'code_expri' => 60,
@@ -22,6 +22,9 @@ class Sms
$sms = AliSms::sendCode($phoneNumber, $code);
if ($sms) {
// 将验证码记录到redis,并设置失效时间
+ // 检查php环境是否有redis拓展
+ // redis服务
+ cache(config('redis.code_pre').$phoneNumber,$code,config('redis.expire'));
}
return true;
@@ -53,7 +53,7 @@ class AliSms
],
])
->request();
- print_r($result->toArray());
+// print_r($result->toArray());
} catch (ClientException $e) {
return false;
// echo $e->getErrorMessage() . PHP_EOL;