# Why does the \`SiteSettings\` class use the \`DistributedCache\` without a \`require 'distributed\_cache';\` statement?

**URL:** https://meta.discourse.org/t/why-does-the-sitesettings-class-use-the-distributedcache-without-a-require-distributed-cache-statement/77580
**Category:** Development
**Created:** [January 9, 2018, 1:39pm UTC](https://meta.discourse.org/t/why-does-the-sitesettings-class-use-the-distributedcache-without-a-require-distributed-cache-statement/77580 "2018-01-09T13:39:36Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![dmitry\_fedyuk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dmitry_fedyuk/32/293153_2.png) [@dmitry\_fedyuk](https://meta.discourse.org/u/dmitry_fedyuk)
#### Post date: [January 9, 2018, 1:39pm UTC](https://meta.discourse.org/t/why-does-the-sitesettings-class-use-the-distributedcache-without-a-require-distributed-cache-statement/77580/1 "2018-01-09T13:39:36Z")

</div>

> <https://github.com/discourse/discourse/blob/v2.0.0.beta1/lib/site_settings/defaults_provider.rb#L12-L12>

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [January 9, 2018, 8:40pm UTC](https://meta.discourse.org/t/why-does-the-sitesettings-class-use-the-distributedcache-without-a-require-distributed-cache-statement/77580/2 "2018-01-09T20:40:48Z")

</div>

What particular issue is this causing?

---

<div class="post-metadata">

### Author: ![dmitry\_fedyuk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dmitry_fedyuk/32/293153_2.png) [@dmitry\_fedyuk](https://meta.discourse.org/u/dmitry_fedyuk)
#### Post date: [January 9, 2018, 10:45pm UTC](https://meta.discourse.org/t/why-does-the-sitesettings-class-use-the-distributedcache-without-a-require-distributed-cache-statement/77580/3 "2018-01-09T22:45:20Z")

</div>

If I use `require 'site_setting_extension'` in my plugin, then I need to remember to add `require 'distributed_cache'` before.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [January 9, 2018, 10:58pm UTC](https://meta.discourse.org/t/why-does-the-sitesettings-class-use-the-distributedcache-without-a-require-distributed-cache-statement/77580/4 "2018-01-09T22:58:38Z")

</div>

The trouble is that now you are initializing site settings earlier than when the app does.

Can you post the exact code of what you are trying to achieve.

---

<div class="post-metadata">

### Author: ![dmitry\_fedyuk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dmitry_fedyuk/32/293153_2.png) [@dmitry\_fedyuk](https://meta.discourse.org/u/dmitry_fedyuk)
#### Post date: [January 9, 2018, 11:44pm UTC](https://meta.discourse.org/t/why-does-the-sitesettings-class-use-the-distributedcache-without-a-require-distributed-cache-statement/77580/5 "2018-01-09T23:44:31Z")

</div>

I use `SiteSettingExtension.module_eval` in my plugins to add custom site setting types, e.g.:

```plaintext
require 'distributed_cache'
require 'site_setting_extension'
SiteSettingExtension.module_eval do
	alias_method :core__types, :types
	def types
		result = @types
		if not result
			result = core__types
			result[:paypal_buttons] = result.length + 1;
		end
		return result
	end
end

```
