0

I encountered a problem with routes cache of Luracast restler. For instance, i have 2 urls:

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

They work with 2 classes correspondingly:

  1. ResaleService
  2. PreconService

When I reach the first url, then in the cache appears info of methods for the first class.

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).

Moreover, when i first go to incorrect url (in purpose) the routes.php cache is saved with an empty array. Then I get 404 on all the urls that i try to reach.

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. Please advice, is it something that i'm doing wrong or this is an incorrect behavior of restler?

Arul Kumaran
  • 983
  • 7
  • 23
yuriscom
  • 550
  • 3
  • 17

1 Answers1

1

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

Ideally when you are in the process of developing the api don't turn on the 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

$r = new Restler(true,true);
Arul Kumaran
  • 983
  • 7
  • 23
  • Thanks for your answer. The problem is that after all the classes are added it still stores only one class in the cache. Steps of reproducing: 1. Added 2 classes: PreconService and ResaleService 2. Cleaned the cache file. 3. Browsed the url of PreconService and got the correct result. The cache is filled with the methods of PreconService class 4. Browsed the url of ResaleService and got error. Cache returned only methods of the PreconService class, not the ResaleService. – yuriscom Sep 07 '12 at 21:26
  • It is not supposed to happen this way. Can you help us by filling a bug using [GitHub Issues](https://github.com/Luracast/Restler/issues) with minimal code to reproduce the issue. We will check and find the solution – Arul Kumaran Sep 08 '12 at 03:05