I programmatically change the value of the availability field in the course_modules database record, so that the module associated with that course_modules record will have an access restriction that depends on the completion of another module in that course. That works just fine.
Programmatically changing that course_modules.availability field was suggested by comments in: https://moodle.org/mod/forum/discuss.php?d=305383
However, after I have updated the course_modules record, and redirect back to the course main page, that page does not correctly display the new access restrictions. The only thing that I have found so far that works is to click the "Purge all caches" hyperlink at the bottom of the page.
Is there something I can do programmatically after I have updated the course_modules record?
Calling purge_by_event() in the following way did not work. I did not find any other event besides 'changesincourse' that seemed relevant.
cache_helper::purge_by_event( 'changesincourse' );