master

laravel/framework

Last updated at: 29/12/2023 09:20

CacheEvent.php

TLDR

The CacheEvent.php file is located in the Illuminate\Cache\Events namespace and defines an abstract class called CacheEvent. This class represents an event that occurs in a cache and includes properties for the event key and tags. It also provides a constructor to instantiate the event with the key and tags, and a method to set or update the tags.

Classes

CacheEvent

The CacheEvent class is an abstract class that represents an event that occurs in a cache. It contains the following properties:

  • key: The key of the event (string).
  • tags : The tags that were assigned to the key (array).

The class includes the following methods:

  • __construct($key, array $tags = []): The constructor method for creating a new CacheEvent instance. It accepts the event key as the first parameter and an optional array of tags as the second parameter.
  • setTags($tags): A method to set or update the tags for the cache event. It accepts an array of tags and returns the instance of the CacheEvent class.
<?php

namespace Illuminate\Cache\Events;

abstract class CacheEvent
{
    /**
     * The key of the event.
     *
     * @var string
     */
    public $key;

    /**
     * The tags that were assigned to the key.
     *
     * @var array
     */
    public $tags;

    /**
     * Create a new event instance.
     *
     * @param  string  $key
     * @param  array  $tags
     * @return void
     */
    public function __construct($key, array $tags = [])
    {
        $this->key = $key;
        $this->tags = $tags;
    }

    /**
     * Set the tags for the cache event.
     *
     * @param  array  $tags
     * @return $this
     */
    public function setTags($tags)
    {
        $this->tags = $tags;

        return $this;
    }
}