Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.4] Factorize cache events. #17120

Merged
merged 1 commit into from
Jan 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/Illuminate/Cache/Events/AbstractCacheEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Illuminate\Cache\Events;

abstract class AbstractCacheEvent
{
/**
* 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;
}
}
19 changes: 0 additions & 19 deletions src/Illuminate/Cache/Events/CacheEvent.php

This file was deleted.

19 changes: 2 additions & 17 deletions src/Illuminate/Cache/Events/CacheHit.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,15 @@

namespace Illuminate\Cache\Events;

class CacheHit extends CacheEvent
class CacheHit extends AbstractCacheEvent
{
/**
* The key that was hit.
*
* @var string
*/
public $key;

/**
* The value that was retrieved.
*
* @var mixed
*/
public $value;

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

/**
* Create a new event instance.
*
Expand All @@ -35,8 +21,7 @@ class CacheHit extends CacheEvent
*/
public function __construct($key, $value, array $tags = [])
{
$this->key = $key;
$this->tags = $tags;
parent::__construct($key, $tags);
$this->value = $value;
}
}
29 changes: 2 additions & 27 deletions src/Illuminate/Cache/Events/CacheMissed.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,7 @@

namespace Illuminate\Cache\Events;

class CacheMissed extends CacheEvent
class CacheMissed extends AbstractCacheEvent
{
/**
* The key that was missed.
*
* @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;
}
//
}
29 changes: 2 additions & 27 deletions src/Illuminate/Cache/Events/KeyForgotten.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,7 @@

namespace Illuminate\Cache\Events;

class KeyForgotten extends CacheEvent
class KeyForgotten extends AbstractCacheEvent
{
/**
* The key that was forgotten.
*
* @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, $tags = [])
{
$this->key = $key;
$this->tags = $tags;
}
//
}
19 changes: 2 additions & 17 deletions src/Illuminate/Cache/Events/KeyWritten.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@

namespace Illuminate\Cache\Events;

class KeyWritten extends CacheEvent
class KeyWritten extends AbstractCacheEvent
{
/**
* The key that was written.
*
* @var string
*/
public $key;

/**
* The value that was written.
*
Expand All @@ -25,13 +18,6 @@ class KeyWritten extends CacheEvent
*/
public $minutes;

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

/**
* Create a new event instance.
*
Expand All @@ -43,8 +29,7 @@ class KeyWritten extends CacheEvent
*/
public function __construct($key, $value, $minutes, $tags = [])
{
$this->key = $key;
$this->tags = $tags;
parent::__construct($key, $tags);
$this->value = $value;
$this->minutes = $minutes;
}
Expand Down