-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
851 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ composer.lock | |
.env | ||
.DS_Store | ||
/.vscode | ||
.phpunit.result.cache | ||
dump.rdb |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
language: php | ||
php: | ||
- 7.1 | ||
- 7.2 | ||
- 7.3 | ||
before_script: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateVisitsTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('visits', function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
$table->string('primary_key'); | ||
$table->string('secondary_key')->nullable(); | ||
$table->unsignedBigInteger('score'); | ||
$table->json('list')->nullable(); | ||
$table->timestamp('expired_at')->nullable(); | ||
$table->timestamps(); | ||
$table->unique(['primary_key', 'secondary_key']); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('visits'); | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Awssat\Visits\Commands; | ||
|
||
use Awssat\Visits\Models\Visit; | ||
use Illuminate\Console\Command; | ||
|
||
class CleanCommand extends Command | ||
{ | ||
protected $signature = 'visits:clean'; | ||
protected $description = '(Laravel-Visits) Clean expired keys and visits.'; | ||
|
||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
public function handle() | ||
{ | ||
$currentEngine = config('visits.engine') ?? ''; | ||
|
||
if($currentEngine == 'eloquent') { | ||
$this->cleanEloquent(); | ||
} | ||
} | ||
|
||
protected function cleanEloquent() | ||
{ | ||
Visit::where('expired_at', '<', \Carbon\Carbon::now())->delete(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Awssat\Visits\DataEngines; | ||
|
||
Interface DataEngine | ||
{ | ||
public function connect(string $connection): self; | ||
public function setPrefix(string $prefix): self; | ||
|
||
public function increment(string $key, int $value, ?string $member = null): bool; | ||
public function decrement(string $key, int $value, ?string $member = null): bool; | ||
|
||
public function delete($key, ?string $member = null): bool; | ||
public function get(string $key, ?string $member = null); | ||
public function set(string $key, $value, ?string $member = null): bool; | ||
|
||
public function flatList(string $key, int $limit): array; | ||
public function addToFlatList(string $key, $value): bool; | ||
public function search(string $word, bool $noPrefix = true): array; | ||
public function valueList(string $search, int $limit = -1, bool $orderByAsc = false, bool $withValues = false): array; | ||
|
||
|
||
public function exists(string $key): bool; | ||
|
||
/** | ||
* @return int seconds, will return -1 if no it has no expiration | ||
*/ | ||
public function timeLeft(string $key): int; | ||
|
||
public function setExpiration(string $key, int $time): bool; | ||
} |
Oops, something went wrong.