Enabled caching for unhashable objects in factories
Trac #16317: UniqueFactory for unhashable elements

Similar to #16316, caching does not work in factories if some of the
parameters
are not hashable.
With this ticket, factories look at the `_cache_key` defined for cached
functions/methods if a parameter is not hashable.

URL: http://trac.sagemath.org/16317
Reported by: saraedum
Ticket author(s): Julian Rueth
Reviewer(s): Peter Bruin