From fb7d7156deec97d79b200148be9121ef399a5f58 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Sat, 4 Oct 2025 15:01:40 +0400 Subject: [PATCH] modifs.mineures sans commentaires --- src/cache/{CacheChannel.php => CursorChannel.php} | 8 ++++---- src/cache/cache.php | 4 ++-- .../cache/{CacheChannelTest.php => CursorChannelTest.php} | 4 ++-- tests/cache/SourceTest.php | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) rename src/cache/{CacheChannel.php => CursorChannel.php} (93%) rename tests/cache/{CacheChannelTest.php => CursorChannelTest.php} (85%) diff --git a/src/cache/CacheChannel.php b/src/cache/CursorChannel.php similarity index 93% rename from src/cache/CacheChannel.php rename to src/cache/CursorChannel.php index 50d214c..1af52b1 100644 --- a/src/cache/CacheChannel.php +++ b/src/cache/CursorChannel.php @@ -8,16 +8,16 @@ use nulib\db\CapacitorStorage; use nulib\php\func; use Traversable; -class CacheChannel extends CapacitorChannel implements IteratorAggregate { - static function with(?iterable $rows=null, $cursorId=null, ?CapacitorStorage $storage=null): self { +class CursorChannel extends CapacitorChannel implements IteratorAggregate { + static function with($cursorId=null, ?iterable $rows=null, ?CapacitorStorage $storage=null): self { $storage ??= cache::storage(); $channel = (new static($cursorId))->initStorage($storage); if ($rows !== null) $channel->rechargeAll($rows); return $channel; } - const NAME = "cache"; - const TABLE_NAME = "cache"; + const NAME = "cursor"; + const TABLE_NAME = "cursor"; const COLUMN_DEFINITIONS = [ "group_id_" => "varchar(32) not null", // groupe de curseur diff --git a/src/cache/cache.php b/src/cache/cache.php index be65764..1f7b8f0 100644 --- a/src/cache/cache.php +++ b/src/cache/cache.php @@ -72,10 +72,10 @@ class cache { self::verifix_id($cursorId); $file ??= "{$cursorId["group_id"]}_{$cursorId["id"]}_rows"; $ccursorId = new CacheFile($file, function() use ($rows, $cursorId) { - CacheChannel::with(null, $cursorId)->rechargeAll($rows); + CursorChannel::with($cursorId, null)->rechargeAll($rows); return $cursorId; }); $noCache = !self::should_cache($cursorId["id"], $cursorId["group_id"]); - return CacheChannel::with(null, $ccursorId->get(null, $noCache)); + return CursorChannel::with($ccursorId->get(null, $noCache)); } } diff --git a/tests/cache/CacheChannelTest.php b/tests/cache/CursorChannelTest.php similarity index 85% rename from tests/cache/CacheChannelTest.php rename to tests/cache/CursorChannelTest.php index 53fc866..63dd7c0 100644 --- a/tests/cache/CacheChannelTest.php +++ b/tests/cache/CursorChannelTest.php @@ -11,7 +11,7 @@ class CacheChannelTest extends _TestCase { ]; function testUsage() { - $channel = CacheChannel::with(self::DATA, "numbers", self::$storage); + $channel = CursorChannel::with("numbers", self::DATA, self::$storage); $count = 0; foreach ($channel as $key => $item) { msg::info("one: $key => {$item["a"]}"); @@ -21,7 +21,7 @@ class CacheChannelTest extends _TestCase { } function testAddColumns() { - $channel = (new class("numbers") extends CacheChannel { + $channel = (new class("numbers") extends CursorChannel { const NAME = "numbersac"; const TABLE_NAME = self::NAME; const ADD_COLUMNS = [ diff --git a/tests/cache/SourceTest.php b/tests/cache/SourceTest.php index 6431f1a..4adece6 100644 --- a/tests/cache/SourceTest.php +++ b/tests/cache/SourceTest.php @@ -10,7 +10,7 @@ use nulib\tests\TestCase; class SourceTest extends TestCase { function test() { $destStorage = new SqliteStorage(new Sqlite(__DIR__.'/dest.db')); - new Capacitor($destStorage, $channel = new CacheChannel("source")); + new Capacitor($destStorage, $channel = new CursorChannel("source")); $sourceDb = new SourceDb(); $channel->rechargeAll($sourceDb->all("select * from source"));