简体   繁体   English

Luracast Restler — route.php缓存

[英]Luracast restler — routes.php cache

I encountered a problem with routes cache of Luracast restler. 我遇到了Luracast restler的路由缓存问题。 For instance, i have 2 urls: 例如,我有2个网址:

  1. /api/service/resale/getmapinfo
  2. /api/service/precon/getmapinfo

They work with 2 classes correspondingly: 它们分别与2个类一起工作:

  1. ResaleService 转售服务
  2. PreconService PreconService

When I reach the first url, then in the cache appears info of methods for the first class. 当我到达第一个URL时,缓存中将显示第一类方法的信息。

Then I try to reach the second url, and then restler reads the cache and finds there only the routes for the first class so i receive a 404 error (because there is no info about the second class). 然后,我尝试访问第二个URL,然后Restler读取缓存,并仅找到第一类的路由,因此我收到404错误(因为没有有关第二类的信息)。

Moreover, when i first go to incorrect url (in purpose) the routes.php cache is saved with an empty array. 此外,当我第一次进入错误的url(故意)时, routes.php缓存将保存为空数组。 Then I get 404 on all the urls that i try to reach. 然后我尝试到达的所有URL上都显示404。

Basically what i see in the code is that the cache system is not based on class, but have one common cache that is written only once, first time when you reach a url. 基本上,我在代码中看到的是,缓存系统不是基于类的,而是具有一个普通的缓存,该缓存仅在您到达URL时第一次写入一次。 Please advice, is it something that i'm doing wrong or this is an incorrect behavior of restler? 请指教,这是我做错了还是这是Restler的不正确行为?

Looks like you need to regenerate the routes.php as you have added new classes and or modified api methods, you can simply delete the routes.php to create new one based on the latest setup 看起来您需要在添加新类和/或修改api方法的情况下重新生成routes.php ,您只需删除routes.php即可根据最新设置创建新的

Ideally when you are in the process of developing the api don't turn on the production_mode 理想情况下,在开发api的过程中,请勿打开production_mode

so instead of 所以代替

$r = new Restler(true); //in production mode

do

$r = new Restler(); //in debug mode, will generate routes every time

or if you want to see the generated routes, but keep overwriting the routes.php every time 或者,如果您想查看生成的路由,但是每次都覆盖一下routes.php

$r = new Restler(true,true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM