Skip to content

How to disable Helm caching for files based operations OR make it less aggressive #2758

Description

@MattMicheletti

Suggestion

Hey Thierry,

I wanted to ask about a semi-frequent issue I have been running into while using Helm. Essentially, Helm has internal caching when it is doing almost any file-based operation (e.g. finding files, listing directories, etc.) and that can often have me run into issues where Helm gets out-of-sync with the real, actual underlying file system due to a stale cache. Often this happens when doing things like running build commands for projects that clean, create, or modify various files and/or directories. Until I found out that Helm had that internal caching, I mistakenly thought certain things weren't working in my projects and spent hours wasting time debugging things, thinking they weren't working when they really were and really did make file system changes.

Description

I recently found out about the helm-refresh command that can be manually invoked during a Helm session on a directory, as needed. However, I wonder if there is a more sophisticated automated solution could be employed here to make the caching either less aggressive or a setting that completely bypasses caching altogether. I was unable to find a clear, easy way to completely turn off caching/disable it entirely for all of Helm.

Solutions

Absent not being able to turn off caching at all, my initial idea is to have a couple of callbacks in some hooks (possibly before/after-init hook for find files)/advice around some methods (:after helm-find-files, :after helm-find-files-up-one-level, :after helm-execute-persistent-action) whereby at least a single refresh is done per each directory visited for the first visit via Helm during a Helm session/command invocation (i.e. doing C-x C-f) but only once for that directory and only for that session, after that the cache takes back over and is in-use for the remainder of that session until the next session/command invocation (whereby the cycle starts all over). In essence, allowing caching to still be used during a session to make traversal still fast after an initial visit to a directory.

What are your thoughts? Is there a better way to solve this issue overall or is this on the right track?

Thanks,
Matt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions