Cache is nearly final


(Alexander Makarov) #1

Spent last week polishing yiisoft/cache. Now I think it looks good. It’s still based on original refactoring idea of @klimov-paul i.e. main Cache class is a wrapper that takes any PSR-16 implementation as constructor argument and extends it with extra features.

Detailed readme is available. Compared to Yii 2:

  1. It’s PSR-16 compatible so both you can use any PSR-16 implementation and the library itself could be used as a PSR-16 implementation.
  2. Cache storage implementations are more polished.
  3. It has modern PHP types.
  4. Expression dependency was replaced with Callback dependency.
  5. Chain dependency was split into Any and All.

There are multiple things to decide on before release though:

  1. Should clear() take key prefix into account?
  2. Do we need add() and addMultiple()? Are there use-cases for these?
  3. PSR-16 requires string keys but we’re supporting any types via serialization. Is this feature useful?
  4. Likely cache storage backends should be moved into separate repositories

Feedback is very welcome.


#2

Are there any implementation issues with add(), addMultiple() or non-string keys?


(Alexander Makarov) #3

No. They’re implemented.


#4

Then why remove it? IMO support for non-string keys is quite convenient. I also don’t remember using add() or addMultiple() in case of cache, but I used similar methods for persistent storage and IMO it could be useful also for cache.

Both changes make component less useful and upgrade from Yii 2 harder, so if there are no good reasons to remove it, IMO they should stay.