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

Added note about refresh and POSIX behavior #648

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rickmcgeer
Copy link

Per the discussion in #647, I've added comments in the initialization block about the fact that refresh = False, the default, will not mimic POSIX behavior of the ls utility.

Comment on lines +215 to +219
*Note that caching creates divergences from the behavior of POSIX utilities such as 'ls'*. In a POSIX
filesystem, ls always returns the current state of a directory; however, if `refresh = False` (the
default), ls returns the state of the cache. `refresh = False` is the default because (unlike in a POSIX filesystem)
listing directory contents of a GCS bucket can be expensive. Developers are advised to set `refresh = True`
if exact POSIX behavior is desired.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't presuppose here what the user's expectations are. Let me have a go, see what you think.

Suggested change
*Note that caching creates divergences from the behavior of POSIX utilities such as 'ls'*. In a POSIX
filesystem, ls always returns the current state of a directory; however, if `refresh = False` (the
default), ls returns the state of the cache. `refresh = False` is the default because (unlike in a POSIX filesystem)
listing directory contents of a GCS bucket can be expensive. Developers are advised to set `refresh = True`
if exact POSIX behavior is desired.
Note that directory listings are cached by default, because fetching those listings can be expensive. This is
contrary to local filesystem behaviour. The cache will be cleared if writing from this instance, but it can
become stale and return incorrect results if the storage is written to from another process/machine.
If you anticipate this possibility, you can set the use_listings_cache and listings_expiry_time arguments
to configure the caching, call `.invalidate_cache()` when required, or pass `refresh=True` to the
various listing methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants