-
Notifications
You must be signed in to change notification settings - Fork 979
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
Daniel Neto
committed
Jun 14, 2024
1 parent
e21f4e0
commit ff0df9c
Showing
4 changed files
with
786 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
require_once $global['systemRootPath'] . 'plugin/Cache/Objects/CachesInDB.php'; | ||
require_once $global['systemRootPath'] . 'plugin/Cache/Objects/CachesInDBMem.php'; | ||
|
||
class CacheDB | ||
{ | ||
public static $loggedType_NOT_LOGGED = 'n'; | ||
public static $loggedType_LOGGED = 'l'; | ||
public static $loggedType_ADMIN = 'a'; | ||
public static $prefix = 'ypt_cache_'; | ||
static $CACHE_ON_DISK = 'disk'; | ||
static $CACHE_ON_MEMORY = 'mem'; | ||
private static $cacheType = 'disk'; | ||
|
||
public static function encodeContent($content) | ||
{ | ||
return CachesInDB::encodeContent($content); | ||
} | ||
|
||
public static function deleteCacheStartingWith($name, $schedule=true) | ||
{ | ||
if($schedule){ | ||
//insert | ||
return Cache_schedule_delete::insert($name); | ||
}else{ | ||
try { | ||
if(self::$cacheType == self::$CACHE_ON_MEMORY){ | ||
return CachesInDBMem::_deleteCacheStartingWith($name); | ||
}else{ | ||
return CachesInDB::_deleteCacheStartingWith($name); | ||
} | ||
} catch (\Throwable $th) { | ||
_error_log("CacheDB::deleteCacheStartingWith($name)"); | ||
} | ||
} | ||
} | ||
|
||
public static function deleteCacheWith($name) | ||
{ | ||
if(self::$cacheType == self::$CACHE_ON_MEMORY){ | ||
return CachesInDBMem::_deleteCacheWith($name); | ||
}else{ | ||
return CachesInDB::_deleteCacheWith($name); | ||
} | ||
} | ||
|
||
public static function deleteAllCache() | ||
{ | ||
if(self::$cacheType == self::$CACHE_ON_MEMORY){ | ||
return CachesInDBMem::_deleteAllCache(); | ||
}else{ | ||
return CachesInDB::_deleteAllCache(); | ||
} | ||
} | ||
|
||
public static function deleteCache($name) | ||
{ | ||
if(self::$cacheType == self::$CACHE_ON_MEMORY){ | ||
return CachesInDBMem::_deleteCache($name); | ||
}else{ | ||
return CachesInDB::_deleteCache($name); | ||
} | ||
} | ||
|
||
public static function getCache($name, $domain, $ishttps, $user_location, $loggedType, $ignoreMetadata = false) | ||
{ | ||
if(self::$cacheType == self::$CACHE_ON_MEMORY){ | ||
return CachesInDBMem::_getCache($name, $domain, $ishttps, $user_location, $loggedType, $ignoreMetadata); | ||
}else{ | ||
return CachesInDB::_getCache($name, $domain, $ishttps, $user_location, $loggedType, $ignoreMetadata); | ||
} | ||
} | ||
|
||
|
||
public static function setBulkCache($cacheArray, $metadata) | ||
{ | ||
if(self::$cacheType == self::$CACHE_ON_MEMORY){ | ||
return CachesInDBMem::setBulkCache($cacheArray, $metadata); | ||
}else{ | ||
return CachesInDB::setBulkCache($cacheArray, $metadata); | ||
} | ||
} | ||
} |
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,45 @@ | ||
<?php | ||
|
||
require_once dirname(__FILE__) . '/../../../videos/configuration.php'; | ||
|
||
class Cache_schedule_delete extends ObjectYPT { | ||
|
||
protected $id,$name; | ||
|
||
static function getSearchFieldsNames() { | ||
return array('name'); | ||
} | ||
|
||
static function getTableName() { | ||
return 'cache_schedule_delete'; | ||
} | ||
|
||
function setId($id) { | ||
$this->id = intval($id); | ||
} | ||
|
||
function setName($name) { | ||
$this->name = $name; | ||
} | ||
|
||
|
||
function getId() { | ||
return intval($this->id); | ||
} | ||
|
||
function getName() { | ||
return $this->name; | ||
} | ||
|
||
public static function insert($name) { | ||
$sql = "INSERT IGNORE INTO cache_schedule_delete (name) VALUES (?)"; | ||
$res = sqlDAL::writeSql($sql, "s", [$name]); | ||
if ($res) { | ||
return true; | ||
} else { | ||
error_log("ObjectYPT::insert::Error on save: " . $sql . " Error : " . json_encode($res)); | ||
return false; | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.