modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2025-10-04 15:01:40 +04:00
parent a34bad04c3
commit fb7d7156de
4 changed files with 9 additions and 9 deletions

View File

@ -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

4
src/cache/cache.php vendored
View File

@ -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));
}
}

View File

@ -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 = [

View File

@ -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"));