欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

laravel 5.8 guzzle get 参数_Laravel速查表 Cache Cookie Request

发布时间:2025/3/20 编程问答 47 豆豆
生活随笔 收集整理的这篇文章主要介绍了 laravel 5.8 guzzle get 参数_Laravel速查表 Cache Cookie Request 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

文档日期:2019年10月31日

链接信息见 https://learnku.com/docs/laravel-cheatsheet/5.8

Cache

// Cache cache() Cache::put('key','value',$second); Cache::put('key','value'); Cache::add('key','value',$seconds); Cache::forever('key','value'); Cache::sear('key',function(){return 'value';}); Cache::remember('key',$sceonds,function(){return 'value';}); Cache::rememberForever('key',function(){return 'value'}); Cache::forget('key'); Cache::has('key'); Cache::get('key','default'); Cache::get('key';function(){return 'default';});// 取到数据后再删除之 Cache::pull('key'); //清空所有缓存 Cache::flush();Cache::increment('key'); Cache::increment('key',$amount); Cache::decrement('key'); Cache::decrement('key'$amount); Cache::tags('my-tag')->put('key','value',$seconds); Cache::tags('my-tag')->has('key'); Cache::tags(['people','artists'])->put('John',$john,$seconds); Cache::tags('my-tag')->forget('key'); Cache::tags('my-tag')->flush(); Cache::tags(['people','artists'])->flush();Cache::section('group')->put('key',$value); Cache::section('group')->get('key'); Cache::section('group')->flush(); Cache::tags(['people','artists'])->put('John',$john,$seconds);// ================辅助函数================== cache('key'); cache(['key'=>'value'],$seconds); cache(['key'=>'value',now()-addMinutes(10));// 使用回调函数操作缓存变量的内容 cache()->remember('users',$seconds,function(){return User::all();});// 执行缓存所使用的驱动 Cache::store('file')->get('foo'); Cache::store('redis')->put('name','Jack',600); // 使用redis缓存10分钟// 事件所引用的类 'IlluminateCacheEventsCacheHit' => ['AppListenersLogCacheHit',], 'IlluminateCacheEventsCacheMissed' => ['AppListenersLogCacheMissed',], 'IlluminateCacheEventsKeyForgotten' => ['AppListenersLogKeyForgotten',], 'IlluminateCacheEventsKeyWritten' => ['AppListenersLogKeyWritten',],

Cookie

cookie(); request()->cookie('name'); Cookie::get('key'); Cookie::get('key','default'); Cookie::forever('key','value'); Cookie::make('key','value','minutes'); cookie('key','value','minutes'); //在回应之前先积累cookie,回应时统一返回 Cookie::queue('key','value','minutes');// 移除cookie Cookie::forget('key'); // 从response发送一个cookie $response = Reponse::make('hello world');// 注意,这个地方传入的过期时间,是一个integer $response->withCookie(Cookie::make('name','value',$minutes)); // 设置未加密 Cookie AppHttpMiddlewareEncryptCookies.php EncryptCookies->except = ['cookie_name_1'];

Request

// 获取请求参数 form-data 与 raw请求类型 request()->input(); // url: http://xx.com//aa/bb Request::url(); Request::path(); Request::getRequestUri(); Request::ip(); Request::getUri(); Request::getQueryString(); Request::getPort(); // 判断当前请求的URI是否可被匹配 Request::is('foo/*'); // 获取URI的分段值,从1开始 Request::segment(1); Request::header('Content-Type'); Request::server('PATH_INFO'); Request::ajax(); Request::secure(); Request::method(); Request::isMethod('post'); //获取原始的post数据 Request::instance()->getContent(); //获取请求要求返回的格式 Request::format(); Request::isJson();// 判断HTTP Accept头部信息是否为 application/json Request::wantsJson();

总结

以上是生活随笔为你收集整理的laravel 5.8 guzzle get 参数_Laravel速查表 Cache Cookie Request的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。