1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 17:44:04 +00:00

Fix Redis scan for 5.8 (#46)

* Fix Redis scan for 5.8

* Add comments [ci skip]
This commit is contained in:
Samuel Štancl 2019-04-24 16:53:43 +02:00 committed by GitHub
parent beb9a0a903
commit 35abb6191d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View file

@ -71,9 +71,16 @@ class RedisStorageDriver implements StorageDriver
return "tenants:{$hash}";
}, $uuids);
$hashes = $hashes ?: $this->redis->scan(null, 'tenants:*');
// Apparently, the PREFIX is applied to all functions except scan()
$redis_prefix = $this->redis->getOption($this->redis->client()::OPT_PREFIX);
$hashes = $hashes ?: $this->redis->scan(null, $redis_prefix.'tenants:*');
return array_map(function ($tenant) use ($redis_prefix) {
// Left strip $redis_prefix from $tenant
if (substr($tenant, 0, strlen($redis_prefix)) == $redis_prefix) {
$tenant = substr($tenant, strlen($redis_prefix));
}
return array_map(function ($tenant) {
return $this->redis->hgetall($tenant);
}, $hashes);
}

View file

@ -202,7 +202,7 @@ class TenantManager
*/
public function all($uuids = [])
{
$uuid = (array) $uuids;
$uuids = (array) $uuids;
return collect(array_map(function ($tenant_array) {
return $this->jsonDecodeArrayValues($tenant_array);