Caching
The only thing the SDK caches is the device auth token — attendance, employee, and other resource data is always fetched live from the device. See Authentication for the full token lifecycle.
Providing a cache
Config accepts any PSR-16 Psr\SimpleCache\CacheInterface implementation via the cache option:
use BioTime\Config;
$config = Config::fromArray([
'ip' => '192.168.1.50',
'username' => 'admin',
'password' => 'secret',
'cache' => $psr16Cache, // any PSR-16 CacheInterface
]);Any PSR-16-compatible cache package works — Symfony Cache's PSR-16 adapter, symfony/cache, or a standalone implementation like cache/simple-cache-bridge, backed by Redis, Memcached, files, or an in-memory array for tests.
Cache key and TTL
Two related Config options control how the token is stored:
| Option | Default | Description |
|---|---|---|
tokenCacheKey | zkteco_device_token | The cache key the token is stored under |
tokenTtlSeconds | 43200 (12 hours) | How long the cached token is considered valid |
$config = Config::fromArray([
// ...
'token_ttl' => 3600, // 1 hour
'token_cache_key' => 'my_app_biotime_token',
]);No cache configured
If cache is null (the default when not explicitly set), the token is kept in an in-memory static array scoped to the current PHP process (TokenManager::$memoryStore). This is enough for a single script, worker, or job run, but does not persist across separate web requests — each new request re-authenticates unless you configure a real cache.
Laravel
Inside Laravel, the bundled service provider automatically injects $this->app['cache.store'] as the cache, so tokens are shared across requests using your app's configured default cache store — no extra setup required. See Laravel installation.