Put back laravel-eloquent-query-cache and remove Caching from previous commit
This commit is contained in:
parent
4d13199848
commit
3ad20f969b
@ -8,13 +8,12 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\FTN\{Message,Packet};
|
||||
use App\Exceptions\InvalidFTNException;
|
||||
use App\Traits\ScopeActive;
|
||||
use App\Traits\{QueryCacheableConfig,ScopeActive};
|
||||
|
||||
/**
|
||||
* This represents an FTN AKA.
|
||||
@ -39,8 +38,8 @@ use App\Traits\ScopeActive;
|
||||
|
||||
class Address extends Model
|
||||
{
|
||||
use ScopeActive,SoftDeletes;
|
||||
const CACHE_KEY = 15;
|
||||
use QueryCacheableConfig,ScopeActive,SoftDeletes;
|
||||
const CACHE_KEY = 0;
|
||||
|
||||
private const LOGKEY = 'MA-';
|
||||
|
||||
@ -798,39 +797,37 @@ class Address extends Model
|
||||
*/
|
||||
public function children(): Collection
|
||||
{
|
||||
return Cache::remember(sprintf('children-%d',$this->id),self::CACHE_KEY,function() {
|
||||
// If we are a point, our parent is the boss
|
||||
switch ($this->role_id) {
|
||||
case self::NODE_NN: // Normal Nodes -> Points
|
||||
return $this->nodes_point;
|
||||
// If we are a point, our parent is the boss
|
||||
switch ($this->role_id) {
|
||||
case self::NODE_NN: // Normal Nodes -> Points
|
||||
return $this->nodes_point;
|
||||
|
||||
case self::NODE_HC: // Hubs -> Normal Nodes
|
||||
return $this->nodes_hub;
|
||||
case self::NODE_HC: // Hubs -> Normal Nodes
|
||||
return $this->nodes_hub;
|
||||
|
||||
case self::NODE_NC: // Nets -> Normal Nodes, excluding Hub's Nodes
|
||||
return $this->nodes_net->diff($this
|
||||
->nodes_net
|
||||
->filter(function($item) { return $item->role_id === Address::NODE_HC; })
|
||||
->transform(function($item) { return $item->children(); })
|
||||
->flatten());
|
||||
case self::NODE_NC: // Nets -> Normal Nodes, excluding Hub's Nodes
|
||||
return $this->nodes_net->diff($this
|
||||
->nodes_net
|
||||
->filter(function($item) { return $item->role_id === Address::NODE_HC; })
|
||||
->transform(function($item) { return $item->children(); })
|
||||
->flatten());
|
||||
|
||||
case self::NODE_RC: // Regions, excluding NC's Nodes
|
||||
return $this->nodes_region->diff($this
|
||||
->nodes_region
|
||||
->filter(function($item) { return $item->role_id === Address::NODE_NC; })
|
||||
->transform(function($item) { return $item->nodes_net; })
|
||||
->flatten());
|
||||
case self::NODE_RC: // Regions, excluding NC's Nodes
|
||||
return $this->nodes_region->diff($this
|
||||
->nodes_region
|
||||
->filter(function($item) { return $item->role_id === Address::NODE_NC; })
|
||||
->transform(function($item) { return $item->nodes_net; })
|
||||
->flatten());
|
||||
|
||||
case self::NODE_ZC: // Zones, excluding RC's Nodes
|
||||
return $this->nodes_zone->diff($this
|
||||
->nodes_zone
|
||||
->filter(function($item) { return $item->role_id === Address::NODE_RC; })
|
||||
->transform(function($item) { return $item->nodes_region; })
|
||||
->flatten());
|
||||
}
|
||||
case self::NODE_ZC: // Zones, excluding RC's Nodes
|
||||
return $this->nodes_zone->diff($this
|
||||
->nodes_zone
|
||||
->filter(function($item) { return $item->role_id === Address::NODE_RC; })
|
||||
->transform(function($item) { return $item->nodes_region; })
|
||||
->flatten());
|
||||
}
|
||||
|
||||
return new Collection;
|
||||
});
|
||||
return new Collection;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -943,38 +940,36 @@ class Address extends Model
|
||||
*/
|
||||
private function ftn_role(): ?int
|
||||
{
|
||||
return Cache::remember(sprintf('ftn_role-%d',$this->id),self::CACHE_KEY,function() {
|
||||
$role = NULL;
|
||||
$role = NULL;
|
||||
|
||||
// If we have a point address, we're a point
|
||||
if ($this->point_id)
|
||||
$role = self::NODE_POINT;
|
||||
// If we have a point address, we're a point
|
||||
if ($this->point_id)
|
||||
$role = self::NODE_POINT;
|
||||
|
||||
// If we have a node_id, we're either a Node or a Hub
|
||||
elseif ($this->node_id) {
|
||||
$role = ($this->nodes_hub->count())
|
||||
? self::NODE_HC
|
||||
: ((($this->role & Address::NODE_ALL) === self::NODE_HC) ? self::NODE_HC : self::NODE_NN);
|
||||
// If we have a node_id, we're either a Node or a Hub
|
||||
elseif ($this->node_id) {
|
||||
$role = ($this->nodes_hub->count())
|
||||
? self::NODE_HC
|
||||
: ((($this->role & Address::NODE_ALL) === self::NODE_HC) ? self::NODE_HC : self::NODE_NN);
|
||||
|
||||
// point_id and node_id are zero
|
||||
// If our region_id !== host_id, and are not zero, and node_id/point_id === 0, we are an NC
|
||||
} elseif (($this->region_id !== $this->host_id) && $this->host_id) {
|
||||
$role = self::NODE_NC;
|
||||
// point_id and node_id are zero
|
||||
// If our region_id !== host_id, and are not zero, and node_id/point_id === 0, we are an NC
|
||||
} elseif (($this->region_id !== $this->host_id) && $this->host_id) {
|
||||
$role = self::NODE_NC;
|
||||
|
||||
// point_id and node_id are zero
|
||||
} elseif (($this->region_id === $this->host_id) && $this->host_id) {
|
||||
$role = self::NODE_RC;
|
||||
// point_id and node_id are zero
|
||||
} elseif (($this->region_id === $this->host_id) && $this->host_id) {
|
||||
$role = self::NODE_RC;
|
||||
|
||||
// point_id and node_id are zero
|
||||
} elseif (($this->region_id === $this->host_id) && (! $this->host_id)) {
|
||||
$role = self::NODE_ZC;
|
||||
}
|
||||
// point_id and node_id are zero
|
||||
} elseif (($this->region_id === $this->host_id) && (! $this->host_id)) {
|
||||
$role = self::NODE_ZC;
|
||||
}
|
||||
|
||||
if (is_null($role))
|
||||
Log::alert(sprintf('%s:! Address ROLE [%d] could not be determined for [%s]',self::LOGKEY,($this->role & Address::NODE_ALL),$this->ftn));
|
||||
if (is_null($role))
|
||||
Log::alert(sprintf('%s:! Address ROLE [%d] could not be determined for [%s]',self::LOGKEY,($this->role & Address::NODE_ALL),$this->ftn));
|
||||
|
||||
return $role;
|
||||
});
|
||||
return $role;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,11 +12,11 @@ use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use App\Casts\CompressedString;
|
||||
use App\Traits\ScopeActive;
|
||||
use App\Traits\{QueryCacheableConfig,ScopeActive};
|
||||
|
||||
class Domain extends Model
|
||||
{
|
||||
use HasFactory,ScopeActive;
|
||||
use HasFactory,QueryCacheableConfig,ScopeActive;
|
||||
|
||||
private const CACHE_TIME = 3600;
|
||||
private const STATS_MONTHS = 6;
|
||||
|
@ -12,11 +12,11 @@ use Illuminate\Support\Facades\Log;
|
||||
use App\Casts\{CollectionOrNull,CompressedString};
|
||||
use App\Classes\FTN\Message;
|
||||
use App\Interfaces\Packet;
|
||||
use App\Traits\{EncodeUTF8,MsgID,ParseAddresses};
|
||||
use App\Traits\{EncodeUTF8,MsgID,ParseAddresses,QueryCacheableConfig};
|
||||
|
||||
final class Echomail extends Model implements Packet
|
||||
{
|
||||
use SoftDeletes,EncodeUTF8,MsgID,ParseAddresses;
|
||||
use SoftDeletes,EncodeUTF8,MsgID,ParseAddresses,QueryCacheableConfig;
|
||||
|
||||
private const LOGKEY = 'ME-';
|
||||
private Collection $set_seenby;
|
||||
|
@ -4,11 +4,11 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\Traits\ScopeActive;
|
||||
use App\Traits\{QueryCacheableConfig,ScopeActive};
|
||||
|
||||
class Zone extends Model
|
||||
{
|
||||
use ScopeActive;
|
||||
use QueryCacheableConfig,ScopeActive;
|
||||
|
||||
/* SCOPES */
|
||||
|
||||
|
17
app/Traits/QueryCacheableConfig.php
Normal file
17
app/Traits/QueryCacheableConfig.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Set defaults of QueryCacheable
|
||||
*/
|
||||
namespace App\Traits;
|
||||
|
||||
use Rennokki\QueryCache\Traits\QueryCacheable;
|
||||
|
||||
trait QueryCacheableConfig
|
||||
{
|
||||
use QueryCacheable;
|
||||
|
||||
public $cacheFor = 900; // cache time, in seconds
|
||||
protected static $flushCacheOnUpdate = TRUE;
|
||||
public $cacheDriver = 'memcached';
|
||||
}
|
@ -14,6 +14,7 @@
|
||||
"ext-zstd": "*",
|
||||
"aglipanci/laravel-eloquent-case": "^3.0",
|
||||
"eduardokum/laravel-mail-auto-embed": "^2.11",
|
||||
"jemmy/laravel-eloquent-query-cache": "dev-master",
|
||||
"laravel/framework": "^11.0",
|
||||
"laravel/sanctum": "^4.0",
|
||||
"laravel/ui": "^4.5",
|
||||
@ -50,6 +51,10 @@
|
||||
"passkey": {
|
||||
"type": "vcs",
|
||||
"url": "https://gitea.dege.au/laravel/passkey.git"
|
||||
},
|
||||
"laravel-eloquent-query-cache": {
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/jemmy/laravel-eloquent-query-cache"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
@ -74,6 +79,6 @@
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
|
79
composer.lock
generated
79
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "f6cba338ad6c538fe04d4e4726c92156",
|
||||
"content-hash": "6f98899a8bd36ac4cc4275d770ebefb5",
|
||||
"packages": [
|
||||
{
|
||||
"name": "aglipanci/laravel-eloquent-case",
|
||||
@ -1329,6 +1329,81 @@
|
||||
],
|
||||
"time": "2023-12-03T19:50:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "jemmy/laravel-eloquent-query-cache",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jemmy/laravel-eloquent-query-cache.git",
|
||||
"reference": "b28777dfefeb7b7d79e08229f845f4c094fc73c1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/jemmy/laravel-eloquent-query-cache/zipball/b28777dfefeb7b7d79e08229f845f4c094fc73c1",
|
||||
"reference": "b28777dfefeb7b7d79e08229f845f4c094fc73c1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/database": "^9.35|^10.5|^11.0",
|
||||
"illuminate/support": "^9.35|^10.5|^11.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"chelout/laravel-relationship-events": "^1.5|^2.0",
|
||||
"laravel/legacy-factories": "^1.3",
|
||||
"livewire/livewire": "dev-master",
|
||||
"mockery/mockery": "^1.5",
|
||||
"orchestra/testbench": "^7.23|^8.1.1",
|
||||
"phpunit/phpunit": "^9.5.25"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Rennokki\\QueryCache\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Rennokki\\QueryCache\\Test\\": "tests"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": [
|
||||
"vendor/bin/phpunit"
|
||||
]
|
||||
},
|
||||
"license": [
|
||||
"Apache-2.0"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alex Renoki",
|
||||
"email": "alex@renoki.org",
|
||||
"homepage": "https://github.com/rennokki",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Adding cache on your Laravel Eloquent queries' results is now a breeze.",
|
||||
"homepage": "https://github.com/jemmy/laravel-eloquent-query-cache",
|
||||
"keywords": [
|
||||
"caching",
|
||||
"eloquent",
|
||||
"laravel",
|
||||
"query",
|
||||
"remember",
|
||||
"sql"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/jemmy/laravel-eloquent-query-cache/tree/master"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/rennokki"
|
||||
}
|
||||
],
|
||||
"time": "2024-05-09T15:02:09+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v11.5.0",
|
||||
@ -8811,7 +8886,7 @@
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": true,
|
||||
"prefer-lowest": false,
|
||||
|
Loading…
Reference in New Issue
Block a user