matthiasmullie / scrapbook

PHP cache library, with adapters for e.g. Memcached, Redis, Couchbase, APC(u), SQL and additional capabilities (e.g. transactions, stampede protection) built on top.
https://www.scrapbook.cash
MIT License
315 stars 27 forks source link

getClient #45

Closed oojacoboo closed 1 year ago

oojacoboo commented 4 years ago

The client property is protected in the Redis adapter, at least. It'd be nice to be able to extend the SimpleCache (PSR-16) and still be able to get the actual client.

matthiasmullie commented 1 year ago

My sincere apologies for this absurdly late reply.

Sadly, I will not implement this: I prefer adapters to expose as little as possible (ideally, not more than dictated by the interface it implements) to make sure it doesn't become part of a public API that needs to remain supported and may complicate future developments.

I would recommend you simply extend the SimpleCache (where you inject the adapter) and also let it accept the Redis adapter. This should allow you to use the full client, without having to fetch it from the adapter.