Symfony 4 - LiipImagine - 如何清除缓存?

azz*_*aze 2 symfony

在 symfony 4 上,我使用 LiipImagineBundle 来显示我的图像。但我注意到存在缓存问题。我的配置是:

# See dos how to configure the bundle: https://symfony.com/doc/current/bundles/LiipImagineBundle/basic-usage.html
liip_imagine:
  # valid drivers options include "gd" or "gmagick" or "imagick"
  driver: "gd"
  filter_sets:
    cache: ~

    # the name of the "filter set"
    avatar_big:
      # adjust the image quality to 75%
      quality: 75

      # list of transformations to apply (the "filters")
      filters:
        # create a thumbnail: set size to 120x90 and use the "outbound" mode
        # to crop the image when the size ratio of the input differs
        thumbnail: { size: [120, 120], mode: outbound }
Run Code Online (Sandbox Code Playgroud)

我的图像位于:

public\images\avatar\
Run Code Online (Sandbox Code Playgroud)

有没有办法自动清除缓存?我看到有订单要下,但我想知道我们是否可以自动化所有这些

Mig*_*Rod 9

如果您打算删除由想象过滤器生成的缓存图像,则 LiipImagineBundle 会向 Symfony 控制台添加一个命令来执行此操作:

php bin/console liip:imagine:cache:remove
Run Code Online (Sandbox Code Playgroud)

如果没有任何参数,您将删除所有路径和所有过滤器的缓存图像。

您可以使用参数将删除范围缩小到您想要的任何过滤器和路径,如下所示:

php bin/console liip:imagine:cache:remove path1 path2 --filters=thumb1 --filters=thumb2
Run Code Online (Sandbox Code Playgroud)

您在这里有更多信息和示例: https://symfony.com/doc/current/bundles/LiipImagineBundle/commands.html#remove-cache