# yatra/3.0.15/app/Repositories/Concerns/CachesQueryResults.php

Yatra – Travel Booking &amp; Tour Operator Software, version 3.0.15. 40 lines.

- Page: https://pluginprobe.com/plugins/yatra/3.0.15/code/app/Repositories/Concerns/CachesQueryResults.php
- Raw: https://pluginprobe.com/plugins/yatra/3.0.15/raw/app/Repositories/Concerns/CachesQueryResults.php
- Modified: 2026-04-14T03:47:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/yatra/3.0.15/code/app/Repositories/Concerns/CachesQueryResults.php#L10-L20`.

```php
<?php

declare(strict_types=1);

namespace Yatra\Repositories\Concerns;

use Yatra\Utils\Cache;

/**
 * Query-result caching for repository classes (DB reads, external API payloads composed here).
 * Do not use for WordPress options — call {@see get_option()} directly without wrapping in {@see Cache}.
 *
 * Pair reads with invalidation on writes: override {@see \Yatra\Repositories\BaseRepository::afterWrite}
 * or fire domain hooks that {@see \Yatra\Hooks\CacheHooks} / {@see \Yatra\Utils\Cache} handle.
 */
trait CachesQueryResults
{
    /**
     * @param callable(): mixed $callback
     *
     * @return mixed
     */
    protected function cacheQueryResult(string $key, callable $callback, int $duration = 3600)
    {
        return Cache::remember($key, $callback, $duration);
    }

    /**
     * Lets application services keep orchestration while storing cache keys and TTLs on the repository.
     *
     * @param callable(): mixed $callback
     *
     * @return mixed
     */
    public function withQueryCache(string $key, callable $callback, int $duration = 3600)
    {
        return $this->cacheQueryResult($key, $callback, $duration);
    }
}

```
