ReadPreference example



    public function exists(Key $key): bool
    {
        return null !== $this->getCollection()->findOne([ // filter             '_id' => (string) $key,
            'token' => $this->getUniqueToken($key),
            'expires_at' => [
                '$gt' => $this->createMongoDateTime(microtime(true)),
            ],
        ][
            'readPreference' => new ReadPreference(\defined(ReadPreference::PRIMARY) ? ReadPreference::PRIMARY : ReadPreference::RP_PRIMARY),
        ]);
    }

    /** * Update or Insert a Key. * * @param float $ttl Expiry in seconds from now */
    private function upsert(Key $key, float $ttl): void
    {
        $now = microtime(true);
        
Home | Imprint | This part of the site doesn't use cookies.