-
-
Notifications
You must be signed in to change notification settings - Fork 561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No caching used in SiteService.GetAllAsync #2080
Comments
Similar issue in AliasService.GetAllAsync |
This is by design, otherwise everything in the entire database would be cached after a single call to |
It is not about everything in database. just the Site data. Thus in SiteService.GetAllAsync just cache and retrieve from cache the all site list, using a key like "ALL_SITES". I saw this pattern used in other services as well. And it hurts performance in the end. |
I think the interesting question here is, when and how are you using What I meant with "everything in the entire database would be cached" is that we don't cache models after calls to |
We are using it so that we don't expose to outside the id of the site. The site we use have a custom field we call "Label". That is used by our client app. Thus our API receives such a "label" and that needs to be matched to a site. For that we get all the sites and check which one has that label set on it. |
In this case I would create a custom service that has its own cache of items of something like this: public class SiteMapping
{
public Guid Id { get; set; }
public string Label { get; set; }
} This way the service could then have methods for fetching a site based on the label by injecting the |
This is exactly what we did, more or less. For mee it seems the services PageService and SiteService treat data differently, and, in my opinion, it should not be so. |
Yes I can see now that there is a discrepancy between how the different services works, I would assume this is an oversight in the content based repositories. We will take a look at how this could be amended to align better. |
While investigating some performance issues, we noticed that the call to SiteService.GetAllAsync does not cache the result at all. The rest of methods that get data from SiteService (ex. GetByIdAsync) use the cache for the results.
Is there any reason why SiteService.GetAllAsync does not use cache? Or is it an oversight?
public async Task<IEnumerable> GetAllAsync()
{
var models = await _repo.GetAll();
}
The text was updated successfully, but these errors were encountered: