amphp / cache

A fiber-aware cache API based on Amp and Revolt.
MIT License
100 stars 15 forks source link

Support amphp/file v2 #12

Closed tlvanknippenberg closed 3 years ago

tlvanknippenberg commented 3 years ago

I have taken the liberty of updating FileCache.php to be inline with the v2 amphp/file methods.

(This is the first time in a long while since I've contributed anything to OSS. Please let me know if I have missed anything.)

enumag commented 3 years ago

Nice! I was planning to take care of this but you were faster. Looks good to me. :-)

kelunik commented 3 years ago

@tlvanknippenberg Thanks! You currently do not have your GPG key uploaded into your account, so your commits show up as Unverified, do you want to fix that? It's not that important, because I'll squash on merge anyway.

kelunik commented 3 years ago

We could also make it compatible with both, I guess? Check whether the new function exists and fallback to the old one?

tlvanknippenberg commented 3 years ago

You currently do not have your GPG key uploaded into your account, so your commits show up as Unverified, do you want to fix that?

Good point. I have added keys to my account for future commits. Thanks!

tlvanknippenberg commented 3 years ago

Regarding the backwards compatibility, would something like this be acceptable? (line 38)

                $files = yield method_exists(File::class, 'listFiles')
                    ? File\listFiles($directory)
                    : File\scandir($directory);
kelunik commented 3 years ago

@tlvanknippenberg Yes, exactly, but we'll need function_exists('Amp\File\listFiles') ? ... : ..., as it's not a method.

kelunik commented 3 years ago

Thanks!