CodeIgniter Forums
Codeigniter Memcached support for SASL? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Codeigniter Memcached support for SASL? (/showthread.php?tid=90390)



Codeigniter Memcached support for SASL? - CIDave - 03-11-2024

Hi!
I'm looking to lock down my memcache server using SASL.
Does CodeIgniter support SASL for Memcache? I saw this in PHP https://www.php.net/manual/en/memcached.setsaslauthdata.php but it doesn't seem it's widely available.


RE: Codeigniter Memcached support for SASL? - kenjis - 03-11-2024

(03-11-2024, 12:26 PM)CIDave Wrote: Hi!
Does CodeIgniter support SASL for Memcache?

No, not yet.
See https://codeigniter4.github.io/CodeIgniter4/libraries/caching.html#memcached-caching
No settings for that.


RE: Codeigniter Memcached support for SASL? - CIDave - 03-12-2024

(03-11-2024, 05:43 PM)kenjis Wrote:
(03-11-2024, 12:26 PM)CIDave Wrote: Hi!
Does CodeIgniter support SASL for Memcache?

No, not yet.
See https://codeigniter4.github.io/CodeIgniter4/libraries/caching.html#memcached-caching
No settings for that.

Not sure if you can help me but...

I modified the CI MemcachedHandler to include the setSaslAuthData method and authentication worked. I needed to also set Raw data to true in order to turn activate this.

But now, when I use the Cache library's get() method, it throws an error:

Quote:Undefined array key 0
Code:
return is_array($data) ? $data[0] : $data;

SYSTEMPATH/Cache/Handlers/MemcachedHandler.php at line 175
When I do a var_dump($data) I can see it is getting my cached results. But because I store my data as an array in the cache, it seems to overwrite the keys of $data.

I.e. I'm doing:

PHP Code:
$this->cache->save($this->hash_key, array("content" => $html"otherData" => 1234"stuff" => 1), $this->defaultCacheTime); 

If I disable the setSaslAuthData method it seems to work okay again. Not sure what is causing this issue.

Also, I noticed that a get() request is being made by System/CodeIgniter.php on every page for a cached file. Anyway to disable this?

PHP Code:
if (($response $this->displayCache($cacheConfig)) instanceof ResponseInterface) {