1
0
mirror of https://github.com/danog/dns.git synced 2024-11-27 04:24:48 +01:00
dns/lib/Cache.php
Chris Wright 3e9fae44c0 Cached null value checks
- Prevent null values from being cached
- Delete values with expired TTLs from memory cached when an attempt is
  made to access them
- Use default TTL when none is specified with Redis and APC
2014-11-19 12:22:42 +00:00

38 lines
886 B
PHP

<?php
namespace Amp\Dns;
interface Cache {
/**
* Default time-to-live - 1 hour
*/
const DEFAULT_TTL = 3600;
/**
* Attempt to retrieve a value from the cache
*
* Callback has the following signature:
* void callback ( bool $cacheHit, string $address )
*
* Called with the following values:
* [true, $valueFromCache] - if it existed in the cache
* [false, null] - if it didn't exist in the cache
*
* @param string $name
* @param int $type
* @param callable $callback
*/
public function get($name, $type, callable $callback);
/**
* Stores a value in the cache. Overwrites the previous value if there was one.
*
* @param string $name
* @param int $type
* @param string $addr
* @param int $ttl
*/
public function store($name, $type, $addr, $ttl);
}