This commit is contained in:
Shish 2023-02-02 16:50:09 +00:00
parent ab874cffd3
commit 9721dc8050
6 changed files with 27 additions and 15 deletions

View file

@ -21,8 +21,12 @@ class EventTracingCache implements CacheInterface
public function get($key, $default=null)
{
if($key === "__etc_cache_hits") return $this->hits;
if($key === "__etc_cache_misses") return $this->misses;
if ($key === "__etc_cache_hits") {
return $this->hits;
}
if ($key === "__etc_cache_misses") {
return $this->misses;
}
$this->tracer->begin("Cache Query", ["key"=>$key]);
$val = $this->engine->get($key, $default);
@ -69,21 +73,24 @@ class EventTracingCache implements CacheInterface
return $val;
}
public function setMultiple($values, $ttl = null) {
public function setMultiple($values, $ttl = null)
{
$this->tracer->begin("Cache Set Multiple");
$val = $this->engine->setMultiple($values, $ttl);
$this->tracer->end();
return $val;
}
public function deleteMultiple($keys) {
public function deleteMultiple($keys)
{
$this->tracer->begin("Cache Delete Multiple");
$val = $this->engine->deleteMultiple($keys);
$this->tracer->end();
return $val;
}
public function has($key) {
public function has($key)
{
$this->tracer->begin("Cache Has", ["key"=>$key]);
$val = $this->engine->has($key);
$this->tracer->end(null, ["exists"=>$val]);
@ -91,7 +98,8 @@ class EventTracingCache implements CacheInterface
}
}
function loadCache(?string $dsn): CacheInterface {
function loadCache(?string $dsn): CacheInterface
{
$matches = [];
$c = null;
if ($dsn && preg_match("#(.*)://(.*)#", $dsn, $matches) && !isset($_GET['DISABLE_CACHE'])) {

View file

@ -7,7 +7,8 @@ namespace Shimmie2;
use GQLA\Expose;
#[Expose(name: "TagUsage")]
class TagUsage {
class TagUsage
{
#[Expose]
public string $tag;
#[Expose]
@ -20,7 +21,8 @@ class TagUsage {
}
#[Expose(extends: "Query", name: "tags", type: '[TagUsage]')]
public static function tags(string $search, int $limit=10): array {
public static function tags(string $search, int $limit=10): array
{
global $cache, $database;
if (!$search) {
@ -66,11 +68,11 @@ class TagUsage {
}
$counts = [];
foreach($res as $k => $v) {
foreach ($res as $k => $v) {
$counts[] = new TagUsage($k, $v);
}
return $counts;
}
}
}
/**

View file

@ -93,12 +93,14 @@ class Comment
}
#[Expose(extends: "Post", name: "comments", type: "[Comment]")]
public function get_comments(Image $post): array {
public function get_comments(Image $post): array
{
return CommentList::get_comments($post->id);
}
#[Expose(extends: "Mutation", name: "create_comment")]
public function create_comment(int $post_id, string $comment): bool {
public function create_comment(int $post_id, string $comment): bool
{
global $user;
send_event(new CommentPostingEvent($post_id, $user, $comment));
return true;

View file

@ -74,7 +74,7 @@ class Featured extends Extension
public function onImageDeletion(ImageDeletionEvent $event)
{
global $config;
if($event->image->id == $config->get_int("featured_id")) {
if ($event->image->id == $config->get_int("featured_id")) {
$config->set_int("featured_id", 0);
$config->save();
}

View file

@ -14,7 +14,7 @@ class GraphQL extends Extension
public function onPageRequest(PageRequestEvent $event)
{
global $page;
if($event->page_matches("graphql")) {
if ($event->page_matches("graphql")) {
$t1 = ftime();
$server = new StandardServer([
'schema' => \GQLA\genSchema(),

View file

@ -11,7 +11,7 @@ class Themelet extends BaseThemelet
global $cache, $config;
$cached = $cache->get("thumb-block:{$image->id}");
if(!is_null($cached)) {
if (!is_null($cached)) {
return $cached;
}