With all the Umbraco Service APIs being for database (CRUD) operations, I'd like to avoid any performance bottlenecks on the frontend.
When I've used RelationService previously, I've ended up writing my own quick-n-dirty caching layer ... but I wonder what others are doing - and if there's a better approach?
Quick and dirty caching layer. If you are running a loadbalanced server make sure that your cache get's refreshed on all servers. You can implement a ICacheRefresher for that
We inherited a few websites with "dirty" caching layers. I like quick, i don't like dirty. :-)
If you use the built-in Umbraco Caching which repopulates if the cache expires, you'll be good to go.
var id = 123;
var valueFromCache = ApplicationContext.ApplicationCache.RuntimeCache.GetCacheItem("cackeykey-123", () =>
{
var myRelation= ApplicationContext.Services.RelationService.GetByParentOrChildId(id);
return myRelation;
});
Using RelationService on the frontend?
Is anyone using the RelationService API on the frontend of their website?
With all the Umbraco Service APIs being for database (CRUD) operations, I'd like to avoid any performance bottlenecks on the frontend.
When I've used RelationService previously, I've ended up writing my own quick-n-dirty caching layer ... but I wonder what others are doing - and if there's a better approach?
Thanks,
- Lee
In the cases where I've done this, I've pretty much done what you have and implemented my own quick and dirty caching!
Quick and dirty caching layer. If you are running a loadbalanced server make sure that your cache get's refreshed on all servers. You can implement a ICacheRefresher for that
Dave
Thanks Tim and Dave ... looks like I'll be sticking with my quick-n-dirty caching! :-P
Good point about the
ICacheRefresher
too!Thanks,
- Lee
We inherited a few websites with "dirty" caching layers. I like quick, i don't like dirty. :-)
If you use the built-in Umbraco Caching which repopulates if the cache expires, you'll be good to go.
LOL. when is said quick and dirty I actually used this way :-)
Yup, same I stick with using
ApplicationCache
too! 👍is working on a reply...