Conversation
…ween L1 cache implementations and their respective state handlers.
…y instantiating L1 concrete classes.
…thods on the StateL1Null class.
…tored 2 loops in StaticL2 to reduce code indentation.
…ial L1 concrete classes for APCu, Static and SQLite.
…s to reduce danger in using the library (maybe added overhead on cache clear).
…l L1 drivers. Had to Refactor StaticL1 for that.
davidstrauss
left a comment
There was a problem hiding this comment.
This is getting very, very close.
src/L1CacheFactory.php
Outdated
| * @param string $pool | ||
| * @return \LCache\APCuL1 | ||
| */ | ||
| protected function createApcu($pool) |
There was a problem hiding this comment.
Should we call this createAPCu?
src/L1CacheFactory.php
Outdated
| * @param string $pool | ||
| * @return \LCache\SQLiteL1 | ||
| */ | ||
| protected function createSqlite($pool) |
There was a problem hiding this comment.
Should we call this createSQLite?
src/StateL1APCu.php
Outdated
| * @return bool | ||
| * True on success, false otherwise. | ||
| */ | ||
| private function _recordEvent($key) |
There was a problem hiding this comment.
Is there a reason this has an underscore prefix?
There was a problem hiding this comment.
It's a personal preference. I like to have all private stuff prefixed with underscore old habit left from development on Yii framework. If it's not ok with the project's naming conventions it fairly easy to change. Though the code sniffer did not complained for that :).
There was a problem hiding this comment.
Done. Also changed the new static variable in the static cache instance.
src/StateL1APCu.php
Outdated
| { | ||
| apcu_store($this->statusKeyHits, 0); | ||
| apcu_store($this->statusKeyMisses, 0); | ||
| // TODO: Decide on how to handle the last applied event state on clear? |
There was a problem hiding this comment.
I think resetting statistics and resetting the last applied event ID should be separate. The latter should, generally, only get flushed when the entire local cache gets flushed.
There was a problem hiding this comment.
So it's ok as it is. I'll just remove the comment.
src/StateL1Null.php
Outdated
| * | ||
| * @author ndobromirov | ||
| */ | ||
| class StateL1Null extends StateL1Static implements StateL1Interface |
There was a problem hiding this comment.
I'm concerned about how this splits the PHP_INT_MAX for getLastAppliedEventID away from NullL1. It allows incorrect behavior when someone uses this state implementation with a stateful L1. As a rule, it should be possible to combine any StateL1 with any L1 and have correct (but maybe not ideal) behavior.
Perhaps, we should just not have a StateL1Null and use StateL1Static with NullL1 when testing.
There was a problem hiding this comment.
I felt something was off when I was implementing this. The only state implementation that caused issues was the NULL one. I think that state should be ok to be the static one. Will change it so.
There was a problem hiding this comment.
State NULL is deleted. On all places the static one is used now. The PHP_INT_MAX was moved back to the NullL1.
|
I think I've missed the NullL1 cache to have it's own L1 test class. |
I'm not sure what you mean. Should I hold off on merging until you make some more changes? |
|
That's it for L1s (for now). I have started working on the L2 but it is going to be tricky there, as I am still getting to know the API and tests for it. You can decide how to do it.
|
I always prefer working incrementally. |
Overview
This pull request implements the described L1 testing changes in #43 for APCu, Static and SQLite drivers.
Summary
There is a new L1CacheTest abstract base class.
There are 3 successors for it, 1 for each driver (APCu, Static, SQLite).
There were some incompatibilities between L1 Implementations and tests:
This is based on top of #73, as the changes here depend on:
Description
All the pure L1 tests are moved to the L1 testing hierarchy.
TODO: L2 and Integrations.