You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I knew that this day would come: Generating a map of the whole API and all its classes is quite cumbersome and isn't a good decision when it comes down to performance. When you also don't have any cache at hand it gets pretty sluggish on every request.
My intention by opening this issue is a refactoring on that topic, so that the class facilitates an autoloader which only loads the class which matches the requested URL. So the first advantage would be that you don't need so much memory by loading any possible class into memory. And on the other side, you have the advantage that you don't have to generate the map for all classes. Just for the requested one and its methods/actions.
Using an autoloader will change the behavior of the RestServer class, so that it loads every class it's able to load. I suggest that there will be a mechanism which prevents certain classes from being autoloaded. Perhaps a class comment like:
/** * @noUse */classDoNotLoadThisClass {}
I consider this as a draft, any opinions on that proposal?
The text was updated successfully, but these errors were encountered:
When I created RestServer I knew there would be performance downsides at some point. I think an autoloader is a good idea. With slight modifications you could put off the parsing of the url mappings to happen only if the baseUrl is matched. $server->addClass('UserAPI', '/users') would be stored but the class wouldn't be loaded or the map generated unless the URL started with '/users'.
I'm happy to merge in any decent solutions you come up with.
Also, not sure if this project fits your needs, but https://github.com/Luracast/Restler is a fork from RestServer and has moved on quite a bit. Development is more active than RestServer.
I knew that this day would come: Generating a map of the whole API and all its classes is quite cumbersome and isn't a good decision when it comes down to performance. When you also don't have any cache at hand it gets pretty sluggish on every request.
My intention by opening this issue is a refactoring on that topic, so that the class facilitates an autoloader which only loads the class which matches the requested URL. So the first advantage would be that you don't need so much memory by loading any possible class into memory. And on the other side, you have the advantage that you don't have to generate the map for all classes. Just for the requested one and its methods/actions.
Using an autoloader will change the behavior of the RestServer class, so that it loads every class it's able to load. I suggest that there will be a mechanism which prevents certain classes from being autoloaded. Perhaps a class comment like:
I consider this as a draft, any opinions on that proposal?
The text was updated successfully, but these errors were encountered: