Replace some global Hash usages with the new thread safe cache.

Summary of the changes:
 * Add thread_safe gem.
 * Use thread safe cache for digestor caching.
 * Replace manual synchronization with ThreadSafe::Cache in Relation::Delegation.
 * Replace @attribute_method_matchers_cache Hash with ThreadSafe::Cache.
 * Use TS::Cache to avoid the synchronisation overhead on listener retrieval.
 * Replace synchronisation with TS::Cache usage.
 * Use a preallocated array for performance/memory reasons.
 * Update the controllers cache to the new AS::Dependencies::ClassCache API.
   The original @controllers cache no longer makes much sense after @tenderlove's
   changes in 7b6bfe84f3 and f345e2380c.
 * Use TS::Cache in the connection pool to avoid locking overhead.
 * Use TS::Cache in ConnectionHandler.
Fix failing test in railties

Related to the HTML route inspector changes:
ae68fc3864e99ab43c18fd12577744e1583f6b64
Revert "Clear url helpers when reloading routes"

This doesn't actually remove old url helper methods as they are
defined in a different module.

This reverts commit 96bcef947bf713b7d9fc88f26dff69f568111262.

Conflicts:
	actionpack/CHANGELOG.md
Clear url helper methods when routes are reloaded

Remove all the old url helper methods when clear! is called on the
route set because it's possible that some routes have been removed.
Removed :if and :unless from fragment cache option in favour of

cache_if(condition, option, &block) and cache_unless(condition, option, &block).

In the PR #8371 was introduced  conditional options :if and :unless in
the cache method.

    Example:

      <%= cache @model, if: some_condition(@model) do %>
        ...
      <%end%>

This is a good feature but *cache_if* and and *cache_unless*
are more concise and close to the standard of rails view helpers
(ex: link_to_if and link_to_unless).

    Example:

      <%= cache_if condition, @model do %>
      ...
      <%end%>
Merge pull request #8497 from acapilleri/conditional_cache

Removed :if / :unless conditions to fragment cache in favour of *cache_i...
Fix for has_many_through counter_cache bug

This commit fixes reported issue #7630 in which counter
caches were not being updated properly when replacing
has_many_through relationships
Improve the documentation of cache_if and cache_unless
Merge pull request #8400 from matthewrobertson/has-many-through-counter-cache

Fix for has_many_through counter_cache bug

Counter caches were not being updated properly when replacing
has_many_through relationships.
Remove AR gem pushed by mistake
Merge pull request #8510 from thedarkone/thread_safety_improvements

Thread safety improvements
remove a cache we do not need
Do not log the binding values for binary columns.

They tend to be large and not very useful in the log.
Revert "Merge pull request #8499 from schneems/schneems/html-route-inspector"

This reverts commit ae68fc3864e99ab43c18fd12577744e1583f6b64, reversing
changes made to 0262a18c7b0ab6f60fee842b3007388f9ffeb0fa.

See here: https://github.com/rails/rails/pull/8499#issuecomment-11356417
Revert "Fix failing test in railties"

This reverts commit 6bdc04624dcc0f45aab93af42d00224f67da36d5.

This has been reverted because https://github.com/rails/rails/commit/8554537e48d6ed18ef08cb3ac0a9da96ac3c5cd6
Merge pull request #8514 from mmb/filter_blob

Do not log the binding values for binary columns.
Convert changelogs to 1.9 hash style and fix some formatting [ci skip]
Skip binary data with binds test for mysql2, fix build

Mysql2 doesn't support binds, which means no binds payload is set when
logging, so the logic to render binary data differently here doesn't work.

Introduced in 99d142a9375f9ba1960863b3cc745265aa9a14df.
Remove unicode character encoding from ActiveSupport::JSON.encode

The encoding scheme (e.g. ☠ -> "\u2620") was broken for characters
not in the Basic Multilingual Plane.  It is possible to escape them
for json using the weird encoding scheme of a twelve-character
sequence representing the UTF-16 surrogate pair (e.g. '𠜎' ->
"\u270e\u263a") but this wasn't properly handled in the escaping code.
Since raw UTF-8 is allowed in json, it was decided to simply pass
through the raw bytes rather than attempt to escape them.