diff options
author | Andrew Dolgov <[email protected]> | 2022-11-23 21:18:40 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2022-11-23 21:18:40 +0300 |
commit | 10a1dd35e3188674db61cce3a2cc64fd5fa1f596 (patch) | |
tree | 27b05853ce1c5562ffb4f028aaf0e7abb9a758bd /classes/cache/adapter.php | |
parent | 30c04adfa661f935f54d3c384bd565319081eb64 (diff) |
* split local cache implementation into a separate class
* allow custom implementations provided by plugins
Diffstat (limited to 'classes/cache/adapter.php')
-rw-r--r-- | classes/cache/adapter.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/classes/cache/adapter.php b/classes/cache/adapter.php new file mode 100644 index 000000000..da69c5bb1 --- /dev/null +++ b/classes/cache/adapter.php @@ -0,0 +1,30 @@ +<?php +interface Cache_Adapter { + public function set_dir(string $dir) : void; + public function get_dir(): string; + public function make_dir(): bool; + public function is_writable(?string $filename = null): bool; + public function exists(string $filename): bool; + /** + * @return int|false -1 if the file doesn't exist, false if an error occurred, size in bytes otherwise + */ + public function get_size(string $filename); + /** + * @param mixed $data + * + * @return int|false Bytes written or false if an error occurred. + */ + public function put(string $filename, $data); + public function touch(string $filename): bool; + public function get(string $filename): ?string; + public function get_full_path(string $filename): string; + /** + * @return false|null|string false if detection failed, null if the file doesn't exist, string mime content type otherwise + */ + public function get_mime_type(string $filename); + /** + * @return bool|int false if the file doesn't exist (or unreadable) or isn't audio/video, true if a plugin handled, otherwise int of bytes sent + */ + public function send(string $filename); + public function expire_all(): void; +} |