Skip to content

Commit

Permalink
Merge f7e028c into 6c2c608
Browse files Browse the repository at this point in the history
  • Loading branch information
hollodotme committed May 12, 2018
2 parents 6c2c608 + f7e028c commit 656304f
Show file tree
Hide file tree
Showing 26 changed files with 824 additions and 86 deletions.
109 changes: 109 additions & 0 deletions .redis/DemoData.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
*8
$4
ZADD
$4
zset
$1
1
$3
one
$1
2
$3
two
$1
3
$25
{"json":{"key": "value"}}
*4
$4
ZADD
$4
zset
$1
2
$9
two again
*3
$3
SET
$6
string
$25
{"json":{"key": "value"}}
*5
$4
SADD
$3
set
$3
one
$3
two
$25
{"json":{"key": "value"}}
*5
$5
RPUSH
$4
list
$3
one
$1
2
$25
{"json":{"key": "value"}}
*4
$4
HSET
$4
hash
$5
field
$5
value
*4
$4
HSET
$4
hash
$4
json
$25
{"json":{"key": "value"}}
*8
$6
GEOADD
$3
geo
$9
13.361389
$9
38.115556
$7
Palermo
$9
15.087269
$9
37.502669
$7
Catania
*9
$5
PFADD
$11
hyperLogLog
$1
a
$1
b
$1
c
$1
d
$1
e
$1
f
$1
g
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a CHANGELOG](http://keepachangelog.com).

## [2.1.0] - YYYY-MM-DD

### Added

**Related to [issue #9]:**

* Output handling for keys of type "set"
* Output handling for keys of type "zset" (sorted sets)
* Output handling for keys of type "list"
* New output of all elements/members/fields in lists, (sorted) sets and hashes
* HyperLogLog prettifier that adds a hint on HLL encoded values

## [2.0.0] - 2018-04-03

### Added
Expand Down Expand Up @@ -65,3 +77,5 @@ First stable release.
[1.1.0]: https://github.com/hollodotme/readis/compare/v1.0.1...v1.1.0
[1.0.1]: https://github.com/hollodotme/readis/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/hollodotme/readis/tree/v1.0.0

[issue #9]: https://github.com/hollodotme/readis/issues/9
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ services:
image: redis:3
ports:
- 6379:6379
volumes:
- ./:/repo
14 changes: 8 additions & 6 deletions src/Application/Configs/IceHawkConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ private function buildReadRoutes() : void
$quotedBaseUri = preg_quote( $baseUrl, '!' );

$this->readRoutes = [
'^' . $quotedBaseUri . '/?$' => ServerSelectionRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)/stats/?$' => ServerStatsRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)(?:/database/(?<database>\d+))?/?$' => ServerDetailsRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)/database/(?<database>\d+)/keys/?$' => AjaxSearchKeysRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)/database/(?<database>\d+)/keys/(?<keyName>.+)/hash/(?<hashKey>.+)/?$' => AjaxKeyDetailsRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)/database/(?<database>\d+)/keys/(?<keyName>.+)/?$' => AjaxKeyDetailsRequestHandler::class,
'^' . $quotedBaseUri . '/?$' => ServerSelectionRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)/stats/?$' => ServerStatsRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)(?:/database/(?<database>\d+))?/?$' => ServerDetailsRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)/database/(?<database>\d+)/keys/?$' => AjaxSearchKeysRequestHandler::class,
'^'
. $quotedBaseUri
. '/server/(?<serverKey>\d+)/database/(?<database>\d+)/keys/(?<keyName>.+)/hash/(?<subKey>.+)/?$' => AjaxKeyDetailsRequestHandler::class,
'^' . $quotedBaseUri . '/server/(?<serverKey>\d+)/database/(?<database>\d+)/keys/(?<keyName>.+)/?$' => AjaxKeyDetailsRequestHandler::class,
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace hollodotme\Readis\Application\Interfaces;

interface ProvidesKeyInformation
interface ProvidesKeyInfo
{
public function getName() : string;

Expand Down
16 changes: 16 additions & 0 deletions src/Application/ReadModel/Constants/KeyType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php declare(strict_types=1);

namespace hollodotme\Readis\Application\ReadModel\Constants;

abstract class KeyType
{
public const HASH = 'hash';

public const LIST = 'list';

public const SET = 'set';

public const SORTED_SET = 'zset';

public const STRING = 'string';
}
45 changes: 45 additions & 0 deletions src/Application/ReadModel/DTO/KeyData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php declare(strict_types=1);

namespace hollodotme\Readis\Application\ReadModel\DTO;

use hollodotme\Readis\Application\ReadModel\Interfaces\ProvidesKeyData;

final class KeyData implements ProvidesKeyData
{
/** @var string */
private $keyData;

/** @var string */
private $rawKeyData;

/** @var null|float */
private $score;

public function __construct( string $keyData, string $rawKeyData, ?float $score = null )
{
$this->keyData = $keyData;
$this->rawKeyData = $rawKeyData;
$this->score = $score;
}

public function getKeyData() : string
{
return $this->keyData;
}

public function getRawKeyData() : string
{
return $this->rawKeyData;
}

public function hasScore() : bool
{
return (null !== $this->score);
}

public function getScore() : ?float
{
return $this->score;
}

}
35 changes: 35 additions & 0 deletions src/Application/ReadModel/DTO/KeyName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php declare(strict_types=1);

namespace hollodotme\Readis\Application\ReadModel\DTO;

use hollodotme\Readis\Application\ReadModel\Interfaces\ProvidesKeyName;

final class KeyName implements ProvidesKeyName
{
/** @var string */
private $keyName;

/** @var null|string */
private $subKey;

public function __construct( string $keyName, ?string $subKey = null )
{
$this->keyName = $keyName;
$this->subKey = $subKey;
}

public function getKeyName() : string
{
return $this->keyName;
}

public function hasSubKey() : bool
{
return (null !== $this->subKey);
}

public function getSubKey() : ?string
{
return $this->subKey;
}
}
8 changes: 8 additions & 0 deletions src/Application/ReadModel/Interfaces/ProvidesHashKeyNames.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php declare(strict_types=1);

namespace hollodotme\Readis\Application\ReadModel\Interfaces;

interface ProvidesHashKeyNames extends ProvidesKeyName
{
public function getHashKeyName() : string;
}
14 changes: 14 additions & 0 deletions src/Application/ReadModel/Interfaces/ProvidesKeyData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php declare(strict_types=1);

namespace hollodotme\Readis\Application\ReadModel\Interfaces;

interface ProvidesKeyData
{
public function getKeyData() : string;

public function getRawKeyData() : string;

public function hasScore() : bool;

public function getScore() : ?float;
}
12 changes: 12 additions & 0 deletions src/Application/ReadModel/Interfaces/ProvidesKeyName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php declare(strict_types=1);

namespace hollodotme\Readis\Application\ReadModel\Interfaces;

interface ProvidesKeyName
{
public function getKeyName() : string;

public function hasSubKey() : bool;

public function getSubKey() : ?string;
}
19 changes: 19 additions & 0 deletions src/Application/ReadModel/Prettifiers/HyperLogLogPrettifier.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php declare(strict_types=1);

namespace hollodotme\Readis\Application\ReadModel\Prettifiers;

use hollodotme\Readis\Application\ReadModel\Interfaces\PrettifiesString;
use function stripos;

final class HyperLogLogPrettifier implements PrettifiesString
{
public function canPrettify( string $data ) : bool
{
return (0 === stripos( $data, 'HYLL' ));
}

public function prettify( string $data ) : string
{
return $data . "\n\n(HyperLogLog encoded value)";
}
}
10 changes: 5 additions & 5 deletions src/Application/ReadModel/Queries/FetchKeyInformationQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ final class FetchKeyInformationQuery
private $keyName;

/** @var null|string */
private $hashKey;
private $subKey;

public function __construct( string $serverKey, int $database, string $keyName, ?string $hashKey )
public function __construct( string $serverKey, int $database, string $keyName, ?string $subKey )
{
$this->serverKey = $serverKey;
$this->database = $database;
$this->keyName = $keyName;
$this->hashKey = $hashKey;
$this->subKey = $subKey;
}

public function getServerKey() : string
Expand All @@ -39,8 +39,8 @@ public function getKeyName() : string
return $this->keyName;
}

public function getHashKey() : ?string
public function getSubKey() : ?string
{
return $this->hashKey;
return $this->subKey;
}
}

0 comments on commit 656304f

Please sign in to comment.