Put tag caching in an sqlite transaction for efficiency

Since we may have a long list of tags to cache, put them all in
one transaction to minimize sqlite overhead.
Merge branch 'cache-tags-in-transaction'

* cache-tags-in-transaction:
  Put tag caching in an sqlite transaction for efficiency