CB Rest API end point cache

Hi,
I am deving my personal blog, with Lucee and latest CB. I started the project with just the rest skelleton, and have since moved it to the root and now have the MVC setup. But I have had this issue since I started.

with a url like …test.local/api/blog/ I get the full listing of my posts. and then i call test.local/api/blog/my-cool-post and it returns the correct data. But then if I go back to test.local/api/blog/ I only get the my-cool-post entry. I have to restart the app to get the full list again.

what setting am I overlooking?

thanks
Tim

Turns out that if you are injecting the QB it will hang on to the last query…
So I removed:

property name="qb" inject="QueryBuilder@qb";

Then just used these in my service:

var qb = wirebox.getInstance( "QueryBuilder@qb" );

Problem solved.

You need to remember that you want a new instance of QueryBuilder@qb each time you do a query, otherwise it’s using the same instance. That’s why var qb = wirebox.getInstance( "QueryBuilder@qb" ); works, it gets a new one each time.

With your injection, you were injecting an instance into your handler once and then reusing it.

// BAD!
property name="qb" inject="QueryBuilder@qb";

You can however inject it using a provider so that it will give you a new instance each time.

// OK
property name="query" inject="provider:QueryBuilder@qb";

Hope that clears things up a bit.