Skip to content

Commit

Permalink
Fix Swoole in-memory table size (#818)
Browse files Browse the repository at this point in the history
* Add can use all available rows test

* Use conflict proportion 1 on TableFactory

---------

Co-authored-by: miguilim <35383529+srdante@users.noreply.github.com>
  • Loading branch information
miguilimzero and miguilimzero authored Jan 20, 2024
1 parent 5a0c867 commit 83c2afb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Tables/TableFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public static function make($size)
static::ensureDependenciesAreLoaded();

return extension_loaded('openswoole')
? new OpenSwooleTable($size)
: new SwooleTable($size);
? new OpenSwooleTable($size, 1)
: new SwooleTable($size, 1);
}

/**
Expand Down
11 changes: 11 additions & 0 deletions tests/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ public function test_it_gets_used_while_creating_an_timer_table()
return $this->assertInstanceOf(SwooleTable::class, $table);
}

public function test_can_use_all_available_rows()
{
$table = $this->createSwooleTable();

for ($i = 0; $i < 1000; $i++) {
$table->set($i, ['string' => 'foo']);
}

$this->assertSame(1000, $table->count());
}

/**
* @dataProvider validStringValues
*/
Expand Down

0 comments on commit 83c2afb

Please sign in to comment.