You've already forked Traefik-Redis-Api
This is not a commit
This commit is contained in:
@@ -20,14 +20,23 @@ class RedisClient
|
||||
* @param ProtocolEnum $type
|
||||
* @return void
|
||||
*/
|
||||
public static function createOrReplace(string $name, array $data, EntityEnum $entity, ProtocolEnum $type = ProtocolEnum::HTTP): void
|
||||
{
|
||||
public static function createOrReplace(
|
||||
string $name,
|
||||
array $data,
|
||||
EntityEnum $entity,
|
||||
ProtocolEnum $type = ProtocolEnum::HTTP
|
||||
): void {
|
||||
self::deleteAllKeys($name, $entity, $type);
|
||||
|
||||
$collection = self::flattenToDotArray($data);
|
||||
|
||||
foreach ($collection as $key => $value) {
|
||||
$redisKey = 'traefik/' . $type->getValue() . '/' . $entity->getValue() . "/$name/" . str_replace('.', '/', $key);
|
||||
$redisKey = 'traefik/' .
|
||||
$type->getValue() . '/' .
|
||||
$entity->getValue() .
|
||||
"/$name/" .
|
||||
str_replace('.', '/', $key);
|
||||
|
||||
Redis::set($redisKey, $value);
|
||||
}
|
||||
}
|
||||
@@ -39,8 +48,12 @@ class RedisClient
|
||||
* @param ProtocolEnum $type
|
||||
* @return void
|
||||
*/
|
||||
public static function patchEntity(string $name, array $data, EntityEnum $entity, ProtocolEnum $type = ProtocolEnum::HTTP): void
|
||||
{
|
||||
public static function patchEntity(
|
||||
string $name,
|
||||
array $data,
|
||||
EntityEnum $entity,
|
||||
ProtocolEnum $type = ProtocolEnum::HTTP
|
||||
): void {
|
||||
$collection = self::flattenToDotArray($data);
|
||||
|
||||
$checkKey = 'traefik/' . $type->getValue() . '/' . $entity->getValue() . "/$name";
|
||||
@@ -58,7 +71,13 @@ class RedisClient
|
||||
$arrayKey = preg_replace('/\.[0-9]+$/', '', $key);
|
||||
|
||||
if (in_array($arrayKey, $cleanedUpKeys)) {
|
||||
$redisKey = 'traefik/' . $type->getValue() . '/' . $entity->getValue() . "/$name/" . str_replace('.', '/', $key);
|
||||
$redisKey = 'traefik/' .
|
||||
$type->getValue() .
|
||||
'/' .
|
||||
$entity->getValue() .
|
||||
"/$name/" .
|
||||
str_replace('.', '/', $key);
|
||||
|
||||
Redis::set($redisKey, $value);
|
||||
|
||||
continue;
|
||||
@@ -73,7 +92,11 @@ class RedisClient
|
||||
$cleanedUpKeys[] = $arrayKey;
|
||||
}
|
||||
|
||||
$redisKey = 'traefik/' . $type->getValue() . '/' . $entity->getValue() . "/$name/" . str_replace('.', '/', $key);
|
||||
$redisKey = 'traefik/' .
|
||||
$type->getValue() . '/' . $entity->getValue() .
|
||||
"/$name/" .
|
||||
str_replace('.', '/', $key);
|
||||
|
||||
Redis::set($redisKey, $value);
|
||||
}
|
||||
}
|
||||
@@ -84,8 +107,11 @@ class RedisClient
|
||||
* @param ProtocolEnum $protocol
|
||||
* @return bool
|
||||
*/
|
||||
public static function deleteAllKeys(string $name, EntityEnum $entity, ProtocolEnum $protocol = ProtocolEnum::HTTP): bool
|
||||
{
|
||||
public static function deleteAllKeys(
|
||||
string $name,
|
||||
EntityEnum $entity,
|
||||
ProtocolEnum $protocol = ProtocolEnum::HTTP
|
||||
): bool {
|
||||
$pattern = 'traefik/' . $protocol->getValue() . '/' . $entity->getValue() . "/$name/*";
|
||||
|
||||
foreach (new Keyspace(Redis::getFacadeRoot(), $pattern) as $key) {
|
||||
@@ -214,4 +240,4 @@ class RedisClient
|
||||
|
||||
return $collection->dot()->toArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user