[CB-5.4.1] Getting a list of all singletons (services, handlers etc) cached

How do I get a list of all singletons (services, handlers etc) cached?

I tried to dump application.wirebox.getCachebox().getKeys() but got the error " The method getKeys was not found in component coldbox.system.cache.CacheFactory.", despite the fact that I can see the method if I do a dump of application.wirebox.getCachebox().

There is no getKeys() method in the cachefactory so I’m not sure what you’re seeing. CacheBox does not store keys directory-- it is a cache aggregator that can have any number of named caches, each using different cache providers (in memory, memcached, redis, etc) To see the keys in a given cache, you’d need to first get the cache in question and then ask for the keys.

cachebox.getCache( 'default' ).getKeys()

Now that said, none of what I just said has anything to do with your original question. Singletons are a concern of WireBox, not CacheBox. If you want to see all the singletons in WireBox, you need to access the singleton scope and look at its contents.

wirebox.getScope( 'singleton' ).getSingletons().keyArray()
1 Like

Cool, thanks, that’s useful.

1 Like