user = $user; $this->config = $config; } /** * @param int $numBuckets * @return string */ public function getBucket($numBuckets = 64) { // Get the bucket config and shift if provided. // Allow us to prevent writing in old filled buckets $config = $this->config->getSystemValue('objectstore_multibucket'); $minBucket = is_array($config) && isset($config['arguments']['min_bucket']) ? (int)$config['arguments']['min_bucket'] : 0; $hash = md5($this->user->getUID()); $num = hexdec(substr($hash, 0, 4)); return (string)(($num % ($numBuckets - $minBucket)) + $minBucket); } }