def _set(self, name, factory, singleton=False, threadlocal=False):
        """
        Add a dependency factory to the registry

        :param name: Name of dependency
        :param factory: function/callable that returns dependency
        :param singleton: When True, makes the dependency a singleton.
            Factory will only be called on first use, subsequent 
            uses receive a cached value.
        :param threadlocal: When True, register dependency as a threadlocal singleton,
            Same functionality as ``singleton`` except :class:`Threading.local` is used
            to cache return values.
        """
        name = name or factory.__name__
        factory._giveme_registered_name = name
        dep = Dependency(name, factory, singleton, threadlocal)
        self._registry[name] = dep