M
M
Michael2017-10-12 17:07:26
Yii
Michael, 2017-10-12 17:07:26

How to delete blocks in Cache in Yii2?

Yii2 allows you to cache arbitrary objects.
For example, I'm caching results from an API. I add the key from the class, function name and parameters. In the future, I will probably redo the method to immediately pass the array directly as a key.
CustomerCustomerRepositoryV1Api -> customerGroupRepositoryV1GetListGet(args)

public function generateCacheKey($class, $method, array $args)
{
    return $class . '->' . $method . '(' . \serialize($args) . ')';
}

Everything works well until the moment when it becomes necessary to delete entire blocks from the cache. I think that it is possible to extend the caching class, but I would like to find a ready-made solution.
Does it exist?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2017-10-12
@springimport

Found. You need to use the so-called Cache Tags which are already implemented in yii.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question