if you want to flush the cache you can do that:
the plugin has functions for that
<?php
flush_pgcache() //page cache
flush_dbcache() // database cache
flush_minify() // minify cache
flush_all() //all caches
?>
and you just need to call it like this:
<?php
$w3_plugin_totalcache->flush_all();
?>
and that is basically the answer to the question in the title
“cache refresh programmatically”