Skip to content

Commit

Permalink
Merge pull request #121 from analogueorm/feature/add-cache-clear
Browse files Browse the repository at this point in the history
Add ability to clear the EntityCache
  • Loading branch information
RemiCollin authored Aug 4, 2016
2 parents 9105b9a + 5f5624b commit 64105d1
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/System/EntityCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class EntityCache

/**
* Entity Map for the current Entity Type
* @var [type]
* @var \Analogue\ORM\EntityMap
*/
protected $entityMap;

Expand Down Expand Up @@ -143,9 +143,9 @@ public function cacheLoadedRelationResult($parent, $relation, $results, Relation
/**
* Create a cachedRelationship instance which will hold related entity's hash and pivot attributes, if any.
*
* @param $parentKey
* @param string $parentKey
* @param string $relation
* @param $result
* @param array $result
* @param Relationship $relationship
* @throws MappingException
* @return CachedRelationship
Expand Down Expand Up @@ -295,7 +295,9 @@ protected function transform(Aggregate $aggregatedEntity)
}

/**
* @param $relation
* Get pivot attributes for a relation
*
* @param string $relation
* @param InternallyMappable $entity
* @return array
*/
Expand All @@ -315,4 +317,17 @@ protected function getPivotValues($relation, InternallyMappable $entity)

return $values;
}

/**
* Clear the entity Cache. Use with caution as it could result
* in impredictable behaviour if the cached entities are stored
* after the cache clear operation.
*
* @return void
*/
public function clear()
{
$this->cache = [];
$this->pivotAttributes = [];
}
}

0 comments on commit 64105d1

Please sign in to comment.