diff --git a/.gitignore b/.gitignore index 0781ae3..25fe6ae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +a.php .phpunit.cache /vendor/ *.cache diff --git a/src/DbAutoProperties.php b/src/DbAutoProperties.php index 19aeaa9..66d3a11 100644 --- a/src/DbAutoProperties.php +++ b/src/DbAutoProperties.php @@ -19,7 +19,7 @@ namespace danog\AsyncOrm; use danog\AsyncOrm\Annotations\OrmMappedArray; -use danog\AsyncOrm\Driver\CachedArray; +use danog\AsyncOrm\Internal\Driver\CachedArray; use danog\AsyncOrm\Settings\DriverSettings; use danog\AsyncOrm\Settings\Mysql; use ReflectionClass; diff --git a/src/FieldConfig.php b/src/FieldConfig.php index b6cbfdf..140cb23 100644 --- a/src/FieldConfig.php +++ b/src/FieldConfig.php @@ -3,7 +3,7 @@ namespace danog\AsyncOrm; use AssertionError; -use danog\AsyncOrm\Driver\CachedArray; +use danog\AsyncOrm\Internal\Driver\CachedArray; use danog\AsyncOrm\Internal\Driver\ObjectArray; use danog\AsyncOrm\Serializer\Json; use danog\AsyncOrm\Settings\DriverSettings; diff --git a/src/Driver/CachedArray.php b/src/Internal/Driver/CachedArray.php similarity index 96% rename from src/Driver/CachedArray.php rename to src/Internal/Driver/CachedArray.php index c73ea3c..fead4bc 100644 --- a/src/Driver/CachedArray.php +++ b/src/Internal/Driver/CachedArray.php @@ -16,11 +16,12 @@ * @link https://daniil.it/AsyncOrm AsyncOrm documentation */ -namespace danog\AsyncOrm\Driver; +namespace danog\AsyncOrm\Internal\Driver; use danog\AsyncOrm\DbArray; use danog\AsyncOrm\FieldConfig; use danog\AsyncOrm\Internal\Containers\CacheContainer; +use Revolt\EventLoop; use Traversable; /** @@ -64,6 +65,7 @@ final class CachedArray extends DbArray public function __destruct() { $this->cache->stopCacheCleanupLoop(); + EventLoop::queue($this->cache->flushCache(...)); } public function flushCache(): void diff --git a/tests/OrmTest.php b/tests/OrmTest.php index 444e636..991809c 100644 --- a/tests/OrmTest.php +++ b/tests/OrmTest.php @@ -23,9 +23,9 @@ use Amp\Process\Process; use Amp\Redis\RedisConfig; use AssertionError; use danog\AsyncOrm\DbObject; -use danog\AsyncOrm\Driver\CachedArray; use danog\AsyncOrm\Driver\MemoryArray; use danog\AsyncOrm\FieldConfig; +use danog\AsyncOrm\Internal\Driver\CachedArray; use danog\AsyncOrm\Internal\Driver\ObjectArray; use danog\AsyncOrm\KeyType; use danog\AsyncOrm\Serializer\Igbinary; @@ -402,7 +402,7 @@ final class OrmTest extends TestCase [ValueType::BOOL, false], // Uncomment when segfaults are fixed - //[ValueType::OBJECT, new TestObject], + [ValueType::OBJECT, new TestObject], [ValueType::SCALAR, 'test'], [ValueType::SCALAR, 123],