Copied to clipboard

Flag this post as spam?

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


  • No1sBothered 7 posts 27 karma points
    Jul 04, 2021 @ 07:34
    No1sBothered
    0

    MemberService Get and Save best practice

    I am saving member information via MemberService and want to know what is the best practice for using MemberService.

    At the moment I am using MembersServices a little like this:

    public class MyClass
    {
    
      private IMemberService _memberService;
    
      public MyClass(IMemberService memberService)
      {
         _memberService = memberService;
      }
    
      public void SaveMyMember(int id)
      {
            var member = _memberService.GetById(id);
            member.SetValue("happy","always") ;
            _memberService.Save(member);
      }
    }
    

    There is a problem with the above code as we are making two calls to the database, one to get the member and one to save the updated member value. This isn't a problem with a few members but at scale, we are seeing Deadlocking problems and believe it would be better to read the member data from Examine, then have a single call to MembersServices to save the member.

    This however doesn't seem to be possible as you need a copy of IMember to pass to _memberService.Save and it looks like the only practical way to get IMember is via _memberService.GetById(id).

    Any ideas, taking into account hundreds of thousands of members and thousands of member update requests per member?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies