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?
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.
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.
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.
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
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.
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.
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
Lucene works like a dream :) Thanks, Chester!
is working on a reply...
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.