久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <small id='9LO1J'></small><noframes id='9LO1J'>

    <i id='9LO1J'><tr id='9LO1J'><dt id='9LO1J'><q id='9LO1J'><span id='9LO1J'><b id='9LO1J'><form id='9LO1J'><ins id='9LO1J'></ins><ul id='9LO1J'></ul><sub id='9LO1J'></sub></form><legend id='9LO1J'></legend><bdo id='9LO1J'><pre id='9LO1J'><center id='9LO1J'></center></pre></bdo></b><th id='9LO1J'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='9LO1J'><tfoot id='9LO1J'></tfoot><dl id='9LO1J'><fieldset id='9LO1J'></fieldset></dl></div>
      <tfoot id='9LO1J'></tfoot>
      <legend id='9LO1J'><style id='9LO1J'><dir id='9LO1J'><q id='9LO1J'></q></dir></style></legend>

          <bdo id='9LO1J'></bdo><ul id='9LO1J'></ul>

      1. Laravel 緩存與 Redis 非常慢

        Laravel Caching with Redis is very slow(Laravel 緩存與 Redis 非常慢)
          <bdo id='w2e2F'></bdo><ul id='w2e2F'></ul>
            1. <i id='w2e2F'><tr id='w2e2F'><dt id='w2e2F'><q id='w2e2F'><span id='w2e2F'><b id='w2e2F'><form id='w2e2F'><ins id='w2e2F'></ins><ul id='w2e2F'></ul><sub id='w2e2F'></sub></form><legend id='w2e2F'></legend><bdo id='w2e2F'><pre id='w2e2F'><center id='w2e2F'></center></pre></bdo></b><th id='w2e2F'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='w2e2F'><tfoot id='w2e2F'></tfoot><dl id='w2e2F'><fieldset id='w2e2F'></fieldset></dl></div>

              1. <tfoot id='w2e2F'></tfoot>
                  <tbody id='w2e2F'></tbody>
                <legend id='w2e2F'><style id='w2e2F'><dir id='w2e2F'><q id='w2e2F'></q></dir></style></legend>

                  <small id='w2e2F'></small><noframes id='w2e2F'>

                • 本文介紹了Laravel 緩存與 Redis 非常慢的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在 Laravel 上使用 Redis 邁出我的第一步,我發現了一些奇怪的東西.

                  I′m making my first steps with Redis on Laravel and there is something odd I figured out.

                  在我的設置中使用 Redis 作為緩存驅動程序時,加載頁面需要很長時間.

                  When using Redis as a cache driver in my setup it is taking far way to much time to load a page.

                  我怎么知道?當不使用 Cache 門面而直接使用 Redis 門面時,響應時間只是一小部分.我從頭開始安裝 Laravel 并為簡單的文章模型構建遷移和播種器.

                  How do I know? When not using the Cache facade but the Redis facade directly response times are just a fraction. I set up a laravel installation on scratch and build a migration and seeder for a simple Article model.

                  首先我認為這些項目沒有存儲在 redis 中,因為在使用 KEYS * 搜索時 redis-cli 沒有顯示它們.我發現緩存存儲在另一個帶有 REDIS_CACHE_DB 的數據庫中,如 config/database.php`redis-cli 中的 INFO 鍵空間列出了這兩個名為 0 和 1 的數據庫.

                  First I thought the items were not stored in redis as redis-cli didn′t show them when searching with KEYS *. I figured out the cache is stored in another DB with REDIS_CACHE_DB as found in config/database.php `INFO keyspace in redis-cli lists those two DB′s named 0 and 1.

                  我認為問題可能是由我使用 Mamp Pro 設置的本地主機引起的.所以我切換到 Laravel Homestead box 并將我的項目上傳到那里.同樣在這里.

                  I thought the problem could be caused by my localhost setup with Mamp Pro. So I switched over to the Laravel Homestead box and uploaded my project there. Same here.

                  這是我正在使用的代碼:路由/web.php

                  Here′s the code I′m using: routes/web.php

                  use IlluminateSupportFacadesRedis;
                  use IlluminateSupportFacadesCache;
                  use IlluminateHttpRequest;
                  use AppArticle;
                  
                  Route::get('/get-articles-mysql', function (Request $request) {
                      return response()->json(Article::take(20000)->get());
                  });
                  
                  
                  Route::get('/get-articles-cache', function (Request $request) {
                      return Cache::remember('posts', 60, function () {
                          return Article::take(20000)->get();
                      });
                  
                  });
                  
                  Route::get('/get-articles-redis', function (Request $request) {
                      if($posts = Redis::get('posts.all')) {
                          return response()->json(json_decode($posts));
                      }
                  
                      $posts = Article::take(20000)->get();
                      Redis::set('posts.all', Article::take(20000)->get());
                      return response()->json($posts);
                  
                  });
                  

                  我正在使用郵遞員來獲取響應時間.我進行了幾次運行,因為當緩存為空時,第一個請求的緩存路由應該很慢.但我得到的平均結果是:

                  I′m using postman to get the response times. I made several runs as the caching routes should be slow on the first request when caching is empty. But what I get on the average is this:

                  http://laravel-echo.local/get-articles-mysql 583ms
                  http://laravel-echo.local/get-articles-redis 62ms
                  http://laravel-echo.local/get-articles-cache 730ms
                  

                  我不明白這個.直接使用 Redis 門面非常快.但為什么緩存這么慢? 是的,我仔細檢查了我的 .env 文件.有 CACHE_DRIVER=redis 所以我不是偶然使用文件系統的.我同時使用了 php artisan config:clearphp artisan cache:clear 以避免調試時出錯.

                  I′m not getting this. Using the Redis facade directly is super-fast. But why is caching so slow? Yes, I double checked my .env files. There is CACHE_DRIVER=redis so I′m not using file system by accident. And I used both php artisan config:clear and php artisan cache:clear to avoid mistakes when debugging.

                  我在 redis-cli 中看到一個名為laravel_cache:posts"的鍵.緩存的帖子在那里.加載它們只需要很長時間.我還在 Chrome 中測試了請求.響應時間要長得多,但緩存仍然比單純的 mysql 查詢需要更多的時間.

                  I see a key called "laravel_cache:posts" in redis-cli. The cached posts are there. It only takes ages to load them. I also tested the requests in Chrome. The response times are much longer but still caching takes more than mere mysql querying.

                  那么有什么建議可能會發生在這里嗎?

                  So any suggestions what could be going on here?

                  推薦答案

                  我知道這個帖子已經很老了,但我還是一樣.

                  I know this thread is already very old, but I am still getting the same.

                  我使用 Laragon 進行本地開發,Redis 使我的 API 請求速度降低了 4 倍.

                  I am using Laragon for local development and Redis makes my API request 4x slower.

                  OMFG...我只是問題所在.

                  OMFG... I just the problem.

                  在我的 .env 文件中,我有REDIS_HOST=localhost",這正是問題所在.

                  In my .env file I had "REDIS_HOST=localhost" and that is exactly the problem.

                  我把它改成REDIS_HOST=127.0.0.1"后,一切都運行得很快.

                  After I change it to "REDIS_HOST=127.0.0.1", everything is running fast.

                  試試看告訴我.

                  這篇關于Laravel 緩存與 Redis 非常慢的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                • <i id='Gm90v'><tr id='Gm90v'><dt id='Gm90v'><q id='Gm90v'><span id='Gm90v'><b id='Gm90v'><form id='Gm90v'><ins id='Gm90v'></ins><ul id='Gm90v'></ul><sub id='Gm90v'></sub></form><legend id='Gm90v'></legend><bdo id='Gm90v'><pre id='Gm90v'><center id='Gm90v'></center></pre></bdo></b><th id='Gm90v'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Gm90v'><tfoot id='Gm90v'></tfoot><dl id='Gm90v'><fieldset id='Gm90v'></fieldset></dl></div>

                      <legend id='Gm90v'><style id='Gm90v'><dir id='Gm90v'><q id='Gm90v'></q></dir></style></legend>
                    1. <small id='Gm90v'></small><noframes id='Gm90v'>

                            <bdo id='Gm90v'></bdo><ul id='Gm90v'></ul>
                              <tbody id='Gm90v'></tbody>
                          • <tfoot id='Gm90v'></tfoot>
                            主站蜘蛛池模板: 国产韩国精品一区二区三区 | 最近免费日本视频在线 | 天天曰夜夜操 | 狠狠色综合久久婷婷 | 青娱乐国产 | 欧美日韩精品一区二区三区蜜桃 | 欧美白人做受xxxx视频 | 天天插天天射天天干 | 久色视频在线观看 | 久久精品欧美一区二区三区不卡 | 一级做a爰片久久毛片免费看 | 3p视频在线观看 | 中文成人在线 | 日韩视频一区 | 午夜a区 | 中文成人在线 | 久久中文视频 | 精品国产18久久久久久二百 | 精品九九 | 欧美久久久久久 | 国产精品日产欧美久久久久 | 五月激情综合网 | 蜜臀网| 精品一区二区三区在线观看国产 | 日韩欧美网 | 亚洲精品一二区 | 日韩一区二区福利 | 羞羞视频在线观看免费观看 | 精品国产一区二区久久 | 日韩精品久久一区 | av手机免费在线观看 | 欧美精品国产一区二区 | 天天射天天操天天干 | 国产免费一区二区 | 日韩中文字幕视频 | 天天操天天拍 | 视频一区二区三区中文字幕 | 丁香婷婷在线视频 | 国产综合在线视频 | 黄在线 | 亚洲午夜精品视频 |