Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Mar 26, 2018 @ 14:43
    Lee Kelleher
    0

    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

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Mar 26, 2018 @ 15:08
    Tim
    1

    In the cases where I've done this, I've pretty much done what you have and implemented my own quick and dirty caching!

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Mar 26, 2018 @ 18:07
    Dave Woestenborghs
    1

    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

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Mar 27, 2018 @ 08:20
    Lee Kelleher
    0

    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

  • Damiaan 442 posts 1301 karma points MVP 6x c-trib
    Mar 27, 2018 @ 12:37
    Damiaan
    1

    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;
    });
    
  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Mar 27, 2018 @ 14:17
    Dave Woestenborghs
    0

    LOL. when is said quick and dirty I actually used this way :-)

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Mar 28, 2018 @ 08:23
    Lee Kelleher
    0

    Yup, same I stick with using ApplicationCache too! 👍

Please Sign in or register to post replies

Write your reply to:

Draft