Insert or update cache record.
Initialize database cache at script startup.
Skip already analyzed templates.  Use cache for it.