cache label names for MUCH quicker scripts when getting many labels
This commit is contained in:
parent
d85fe08504
commit
a6bb48ef96
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
class Repo{
|
class Repo{
|
||||||
|
|
||||||
|
private $cache=[];
|
||||||
|
|
||||||
public function __construct(Client $client,$user,$repo){
|
public function __construct(Client $client,$user,$repo){
|
||||||
$this->client=$client;
|
$this->client=$client;
|
||||||
$this->user=$user;
|
$this->user=$user;
|
||||||
@ -29,9 +31,12 @@ class Repo{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getLabelByName($name){
|
public function getLabelByName($name){
|
||||||
|
if(!$this->cache['lables']){
|
||||||
$url="repos/{$this->user}/{$this->repo}/labels";
|
$url="repos/{$this->user}/{$this->repo}/labels";
|
||||||
$data=$this->client->request($url);
|
$this->cache['lables']=$this->client->request($url);
|
||||||
foreach($data as $datum){
|
}
|
||||||
|
|
||||||
|
foreach($this->cache['lables'] as $datum){
|
||||||
if($datum->name==$name){
|
if($datum->name==$name){
|
||||||
$datum->url=$url."/".$datum->id; // not set by api for some reason (bug?)
|
$datum->url=$url."/".$datum->id; // not set by api for some reason (bug?)
|
||||||
return new Label($this,$datum);
|
return new Label($this,$datum);
|
||||||
|
Loading…
Reference in New Issue
Block a user