1
0

RoundRobinShardMapper.php 444 B

1234567891011121314151617181920
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Robin Appelman <robin@icewind.nl>
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\DB\QueryBuilder\Sharded;
  8. use OCP\DB\QueryBuilder\Sharded\IShardMapper;
  9. /**
  10. * Map string key to an int-range by hashing the key
  11. */
  12. class RoundRobinShardMapper implements IShardMapper {
  13. public function getShardForKey(int $key, int $count): int {
  14. return $key % $count;
  15. }
  16. }