💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# thinkphp使用redis ``` <pre class="calibre15">``` <span class="token3">publicfunction redis</span><span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span> $redis <span class="token">=</span> <span class="token2">new</span> <span class="token3"><span class="token1">\</span><span class="token1">\</span>Redis</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $redis<span class="token">-</span><span class="token">></span><span class="token3">connect</span><span class="token1">(</span><span class="token4">'127.0.0.1'</span><span class="token1">,</span> <span class="token5">6379</span><span class="token1">)</span><span class="token1">;</span> <span class="token6">// $redis->auth('password'); # 如果没有密码则不需要这行</span> <span class="token6">//把 'test'字符串存入 redis</span> $redis<span class="token">-</span><span class="token">></span><span class="token2">set</span><span class="token1">(</span><span class="token4">'test\_name'</span><span class="token1">,</span> <span class="token4">'test'</span><span class="token1">)</span><span class="token1">;</span> <span class="token6">// 把 'test\_name' 的 值从 redis 读取出来 </span> echo $redis<span class="token">-</span><span class="token">></span><span class="token2">get</span><span class="token1">(</span><span class="token4">'test\_name'</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> ``` ```