summaryrefslogtreecommitdiff
path: root/classes/cache/Cache_interface.php
blob: 7c497894502ce5850e574c3a79f695fee3807c1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

/** Cache interface
 * ---
 * Interface to save results of expensive data-extraction proccess,
 * in a fast-accessed medium (ussually RAM or NVME SSD units)
 */
interface Cache_interface
{
    /** Cache::set($key, $data, $ttl) : void
     * 
     * @param $key (string): reference label
     * @param $data (mixed): actual data (avoid storing true|false)
     * @param $ttl (int): time to live (seconds)
     */
    public function set(string $key, $data, int $ttl);


    /** Cache::get($key) : mixed
     *
     * @param $key (string)
     * @return mixed: fetched $data -or- false on failure
     */
    public function get(string $key);


    /** Cache::flush( $olderThan ) : void
     *
     * clear cache older than $olderThan
     * @param $olderThan (int) in seconds
     */
    public function flush(int $olderThan = 0);

}