Caching

Introduction

Besides Laravel cache you may use domain-linked caching. Domain-linked caching is similar to caching with tags but automated around configured streams.

Configuration

Domain-linked caching uses the default Laravel storage driver.

Basic Usage

You can interact with domain-linked cache stores directly using stream instances.

Inserting Items

You can insert an item into domain-linked cache for a given number of seconds using the cache method:

Streams::make('contacts')->cache('favorites', 600, function() {
    return $this->entries()->where('favorited', true)
});

Retrieving Items

You can retreive cached items using the cached method:

$favorites = Streams::make('contacts')->cached('favorites');

Forgetting Items

You can forget a specific domain-linked cached item using the forget method:

Streams::make('contacts')->forget('favorites');

You can forget all domain-linked cached items for a stream using the flush method:

Streams::make('contacts')->flush();

Write operations automatically forget/flush cache.

Related Documentation