-
Notifications
You must be signed in to change notification settings - Fork 5
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
\RavenDB\Documents\Commands\GetDocumentsCommand::withStartWith() throw on not null but empty prefix #57
Comments
Can you explain what your scenario is for using |
Yes indeed, with a limit of 1000 documents ( via the |
But if I'm going on the wrong way, just tell me what alternative to use :P I'm only looking for a way to fetch up to 1000 documents (metadata only, I don't need the rest) with an optional "matches" parameter. |
Can you go back a step? What is the actual scenario? You want to find 1000 documents based on their id? Note that if you Basically:
I assume that this isn't what you want. |
Not exactly, I have a public API that allow users to retrieve all the cache items (the objects stored in Ravendb) with a maximum hard-limit of 999 items. This public API have an optional "$pattern" parameter that I successfully bound to Ravendb: /**
* @return array<int, string>
* @throws PhpfastcacheDriverException
* @throws PhpfastcacheInvalidArgumentException
*/
protected function driverReadAllKeys(string $pattern = ''): iterable
{
$keys = [];
if (empty($this->documentPrefix)) {
throw new PhpfastcacheUnsupportedMethodException('A document prefix must be configured and not empty to be able to load all items from Raven.');
}
$results = $this->instance->loadStartingWith(
RavenProxy::class,
$this->documentPrefix,
$pattern,
0,
ExtendedCacheItemPoolInterface::MAX_ALL_KEYS_COUNT
);
if (is_iterable($results)) {
/** @var RavenProxy $item */
foreach (iterator_to_array($results) as $item) {
$keys[] = $item->getKey();
}
}
return $keys;
} So to bypass this "error", I made the prefix mandatory so the |
What is the meaning of the |
It is like a "I want all the cache item that contain And I wrap the keyword with But the pattern is working well, it's just the |
The issue is that this works as long as you have a small amount of data. But if you have 1M items, you may need to scan through all of those.
So add the ability to tag a cache item (with multiple tags), then allow to query on that. This will result in both better API and use case, I think. |
Tags already exists and are handled well on my side, but don't bother about the pattern, it is not the issue here 😂 So; short version: I'd like to be all to grab the 999 first documents without having to provide |
That is indeed a bug, and we can fix that. @alxsabo The actual use case is probably better off with a query, rather that |
Ok. I will make a bug fix for this issue. |
Aside topic: Do the ravendb client is Semver-compliant ? Because I found changes that are completely breaking between 5.21 et 5.2.6 :( |
There shouldn't be any breaking changes, only additional APIs |
Can you tell us what changes you found? |
PHP version changes from 8.0 to 8.1 minimum in between 2 PATCH version :( So basically when my CI is running, composer rollback from 5.2.6 to 5.2.1 to run the tests which make new methods added between 5.2.1 and 5.2.6 suddenly unavailable :( Because Phpfastcache runs from 8.0 up to 8.4, so the Github Actions runs the tests on each of them. |
Yes, we update minimum version of PHP to be 8.1, and RavenDB cant be run on PHP 8.0 |
Yes, that was a breaking changes, for being Semver compliant this change should have occurred on a MINOR or MAJOR version. |
Thank you for raising this concern. We'll ensure better backward compatibility in our future updates. |
This is something I'm very vigilant to since I took the Phpfastcache library 8 years ago. I will continue my implementation on my side until I consider it stable enough to make an official release of Ravendb support on Phpfastcache. Thanks for the quick support however ! |
Hello,
Method
\RavenDB\Documents\Commands\GetDocumentsCommand::withStartWith
throw when$startWith
is an empty string (but is not null), while an empty string is working and theoretically a valid prefix.Solution:
Replace:
by:
The text was updated successfully, but these errors were encountered: