<p>If you look at the MemCacheConfig.php file, you'll see that it's expecting a single property, "servers", which contains an array of associative arrays with properties. So, try this as your memcache config:</p>

<pre><code>&lt;?php
return [
    'servers' =&gt; 
[
  [        // A memcached server hostname or IP address.
             'host' =&gt; 'localhost',
             // Whether or not to use a persistent connection.
             'persistent' =&gt; true,
             // The memcached server port.
             'port' =&gt; 11211,
             // How often a failed server will be retried (in seconds).
             'retryInterval' =&gt; 15,
             // If the server should be flagged as online upon a failure.
             'status' =&gt; true,
             // The value in seconds which will be used for connecting to the server.
             'timeout' =&gt; 15,
             // Probability of using this server among all servers.
             'weight' =&gt; 1,
    ]
  ]
];
</code></pre>

CC BY-SA 3.0
2017-08-16T19:34:58.677Z
2017-08-16T19:34:58.677Z
Ransom
<p>Is there any configuration hint for enabling memcache in Craft 3? I'm on 3-beta-24</p>

<p>I added</p>

<pre><code>'cacheMethod' =&gt; 'memcache',
</code></pre>

<p>to config/general.php, but this did neither cause any hits on memcache nor any error.</p>

<p>The Craft 2 (sic!) docs say you also need <em>config/memcache.php</em>, which I created</p>

<ol>
<li>returning an empty array</li>
<li>returning an array containing the properties I found in *app/vendor/craftcms/cms/src/config/MemCacheConfig.php:</li>
<li>returning a 2 dimensional array with the the first array containing the properties from 2. above</li>
</ol>

<p>Nothing worked, but 2. &amp; 3. throw unknown property exceptions.</p>

<p>This is my memcache.php (according to variant 3. above):</p>

<pre><code>return [
    [        // A memcached server hostname or IP address.
        'host' =&gt; 'localhost',
        // Whether or not to use a persistent connection.
        'persistent' =&gt; true,
        // The memcached server port.
        'port' =&gt; 11211,
        // How often a failed server will be retried (in seconds).
        'retryInterval' =&gt; 15,
        // If the server should be flagged as online upon a failure.
        'status' =&gt; true,
        // The value in seconds which will be used for connecting to the server.
        'timeout' =&gt; 15,
        // Probability of using this server among all servers.
        'weight' =&gt; 1,
    ]
];
</code></pre>

<p>This is the exception:</p>

<pre><code>Unknown Property – yii\base\UnknownPropertyException
Setting unknown property: craft\config\MemCacheConfig::0
 in .../app/vendor/yiisoft/yii2/base/Object.php at line 161
</code></pre>

<p>looks like the config can't handle multiple memcache servers as array.</p>

<p>Here's the stacktrace: <a href="https://pastebin.ca/3855627" rel="nofollow noreferrer">https://pastebin.ca/3855627</a></p>

CC BY-SA 3.0
2017-08-15T20:26:29.550Z
`'cacheMethod' => 'memcache'` is correct and #3 is correct. What was the error you were getting in that situation? And is memcache installed locally and are you able to connect to it with those settings from the command line?
Brad Bell
CC BY-SA 3.0
2017-08-15T20:46:16.757Z
With #3 I get:
Unknown Property – yii\base\UnknownPropertyException
Setting unknown property: craft\config\MemCacheConfig::0

I have memcache enabled in MAMP, though not verified it works. But I would expect some "can not connect" error or successful hits in the memcache log. Neither happens.
Matthias Redl-Mann
CC BY-SA 3.0
2017-08-15T20:54:31.843Z
Can you edit the original question and share the error with the full stack trace leading up to it?  As well as the full contents of your `craft/config/memcache.php` file.
Brad Bell
CC BY-SA 3.0
2017-08-15T21:06:47.360Z
did it. do you really want the full stack trace?
Matthias Redl-Mann
CC BY-SA 3.0
2017-08-15T21:16:48.393Z
Yeah, full stack trace, please. Trying to determine if this is a Craft 3 bug or not.
Brad Bell
CC BY-SA 3.0
2017-08-16T07:54:52.153Z
added it in the post with a link to pastebin
Matthias Redl-Mann
CC BY-SA 3.0
2017-08-16T12:20:27.333Z
additional info: apart from that config issue, craft seems to be looking for the php memcache extension, because I deployed on a different system without the memcache extension and there I got an error. But Craft does not seem to use the memcache server, because I have no hits on my local memcache in mamp and also disabling it does not make a difference to my local dev craft.
Matthias Redl-Mann
CC BY-SA 3.0
2017-08-16T20:19:13.303Z
Ahh... @Ransom's answer is probably the issue.
Brad Bell
<cache><config><craft3>
Craft 3: Enabling Memcache
# Craft 3: Enabling Memcache

(Asked by: username_0 on 2017-08-15)

Is there any configuration hint for enabling memcache in Craft 3? I'm on 3-beta-24
I added
'cacheMethod' => 'memcache',

to config/general.php, but this did neither cause any hits on memcache nor any error.
The Craft 2 (sic!) docs say you also need config/memcache.php, which I created

returning an empty array
returning an array containing the properties I found in *app/vendor/craftcms/cms/src/config/MemCacheConfig.php:
returning a 2 dimensional array with the the first array containing the properties from 2. above

Nothing worked, but 2. & 3. throw unknown property exceptions.
This is my memcache.php (according to variant 3. above):
return [
    [        // A memcached server hostname or IP address.
        'host' => 'localhost',
        // Whether or not to use a persistent connection.
        'persistent' => true,
        // The memcached server port.
        'port' => 11211,
        // How often a failed server will be retried (in seconds).
        'retryInterval' => 15,
        // If the server should be flagged as online upon a failure.
        'status' => true,
        // The value in seconds which will be used for connecting to the server.
        'timeout' => 15,
        // Probability of using this server among all servers.
        'weight' => 1,
    ]
];

This is the exception:
Unknown Property – yii\base\UnknownPropertyException
Setting unknown property: craft\config\MemCacheConfig::0
 in .../app/vendor/yiisoft/yii2/base/Object.php at line 161

looks like the config can't handle multiple memcache servers as array.
Here's the stacktrace: https://pastebin.ca/3855627

**Tags:** cache, config, craft3

> **Comments:**
> **username_1**: `'cacheMethod' => 'memcache'` is correct and #3 is correct. What was the error you were getting in that situation? And is memcache installed locally and are you able to connect to it with those settings from the command line?  
> **username_0**: With #3 I get: Unknown Property – yii\base\UnknownPropertyException Setting unknown property: craft\config\MemCacheConfig::0  I have memcache enabled in MAMP, though not verified it works. But I would expect some "can not connect" error or successful hits in the memcache log. Neither happens.  
> **username_1**: Can you edit the original question and share the error with the full stack trace leading up to it?  As well as the full contents of your `craft/config/memcache.php` file.  
> **username_0**: did it. do you really want the full stack trace?  
> **username_1**: Yeah, full stack trace, please. Trying to determine if this is a Craft 3 bug or not.  
> **username_0**: added it in the post with a link to pastebin  
> **username_0**: additional info: apart from that config issue, craft seems to be looking for the php memcache extension, because I deployed on a different system without the memcache extension and there I got an error. But Craft does not seem to use the memcache server, because I have no hits on my local memcache in mamp and also disabling it does not make a difference to my local dev craft.  
> **username_1**: Ahh... @username_2's answer is probably the issue.  

---

## 1 answers

### Answer by username_2 on 2017-08-16. Score: 2 | Accepted answer

If you look at the MemCacheConfig.php file, you'll see that it's expecting a single property, "servers", which contains an array of associative arrays with properties. So, try this as your memcache config:
 
[
  [        // A memcached server hostname or IP address.
             'host' => 'localhost',
             // Whether or not to use a persistent connection.
             'persistent' => true,
             // The memcached server port.
             'port' => 11211,
             // How often a failed server will be retried (in seconds).
             'retryInterval' => 15,
             // If the server should be flagged as online upon a failure.
             'status' => true,
             // The value in seconds which will be used for connecting to the server.
             'timeout' => 15,
             // Probability of using this server among all servers.
             'weight' => 1,
    ]
  ]
];


---

