Invalidating the cache tag from a plugin? I have a plugin that renders HTML via a hook.  If someone wraps that hook with {% cache %} in their templates, how can my plugin tell Craft to invalidate the cache when something within it changes?

EDIT: Let's say, for example, that I'm getting JSON data from an external source via my plugin.  I could be rendering this via a hook, or using a Variable, it doesn't matter that much.

There's no Element that the content that changes can be linked to, in order to invalidate the cache.
The TemplateCacheService provides a ton of helpful methods to take care of this for you.

While you can explicitly tell Craft to invalidate certain caches (by element ID, etc.) if you need to, I prefer to use includeCriteriaInTemplateCaches() and includeElementInTemplateCaches() to register the appropriate element(s)/criteria with the template cache, so that Craft takes care of cache invalidation according to its own internal logic:

$myCrtieria = ... ; // (some ElementCriteriaModel)

$cacheService = craft()-&gt;getComponent('templateCache', false);

if ($cacheService)
{
    $cacheService-&gt;includeCriteriaInTemplateCaches($myCriteria);
}  


...

p.s. Unless you really need to render HTML via a Twig hook, I strongly suggest refactoring to use a custom Template Variable instead. Doing so is more consistent with Craft's own internal practice. Twig hooks are typically used to change context variables and perform other logic that is specific to changing how Twig renders templates. For doing content-related business logic (e.g. fetching data from the database and rendering it into templates), using Craft's provided structures will save you trouble down the road.