Copied to clipboard

Flag this post as spam?

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


  • Snake Plissken 3 posts 83 karma points
    Feb 13, 2020 @ 14:14
    Snake Plissken
    0

    Getting all members, but faster

    Hey guys, call me Snake.

    I'm running a scheduled server task to send out emails to the registered members. Those members have a property called "ReceivedEmail" and it basically lets us know whether or not the member has received the email or not.

    The catch is, that I am using the GetAllMembers() method from the Umbraco member service, which I find to be very slow performing. Please note, that I have a total of +16'000 members I need to fetch, and loop through them to retrieve the flag "ReceivedEmail".

    My logs say that the whole operation lasts about 2 hours, and I don't really want to be running a scheduled task for that long.

    What would be the best approach to fetch those members fast and with the flag set to false?

    Many thanks, Snake

  • Chester Campbell 65 posts 123 karma points
    Feb 13, 2020 @ 14:44
    Chester Campbell
    0

    Hi Snake,

    One option would be to create a member Lucene search index. Create your own indexer that is attached to the member-save event.

    Then in your scheduled task do a lucene search for the members you want and either pull all the data you need form the search index or use the member id to get the member from the API.

  • Snake Plissken 3 posts 83 karma points
    Feb 13, 2020 @ 14:49
    Snake Plissken
    0

    Hey Chester,

    Thanks for the answer. Since I am very unfamiliar with Lucene so wonder, if the index is something that needs to be ran through all the members again, wouldn't that index need to be run every time a new member registers?

    The amount of members is very dynamic, and I have to make sure that each and every single one of the new members gets included in the scheduled-task loop.

    Just a side note: The scheduled task runs every night at 12pm.

  • Chester Campbell 65 posts 123 karma points
    Feb 13, 2020 @ 19:02
    Chester Campbell
    100

    Yes, you would want to tie your custom indexer to whatever events fire when members are created ... either in the CMS or if you're creating them in your own code.

    Here's info on subscribing to events: https://our.umbraco.com/Documentation/Getting-Started/Code/Subscribing-To-Events/index-v7

    Here's info on member service events (looks like the Created event is what you need): https://our.umbraco.com/apidocs/v7/csharp/api/Umbraco.Core.Services.MemberService.html#events

  • Snake Plissken 3 posts 83 karma points
    Feb 18, 2020 @ 14:24
    Snake Plissken
    0

    Lucene works like a dream :) Thanks, Chester!

Please Sign in or register to post replies

Write your reply to:

Draft