Skip to content

DatastoreSessionHandler how to set "excludeFromIndexes" for "data" field? #506

Description

@dmitriytestapic

I want to exclude "data" field because my session data are large than 1500 bytes and I get an error while writing session. Is there another way without changing library code?

Google\Cloud\Datastore\DatastoreSessionHandler

  public function write($id, $data)
   {
       try {
           $key = $this->datastore->key(
               $this->kind,
               $id,
               ['namespaceId' => $this->namespaceId]
           );
           $entity = $this->datastore->entity(
               $key,
               [
                   'data' => $data,
                   't' => time()
               ],
               [
                   'excludeFromIndexes' => ['data'] // I want to pass it
               ]
           );
           $this->transaction->upsert($entity);
           $this->transaction->commit();
       } catch (Exception $e) {
           trigger_error(
               sprintf('Datastore upsert failed: %s', $e->getMessage()),
               E_USER_WARNING
           );
           return false;
       }
       return true;
   }

Metadata

Metadata

Assignees

Labels

api: datastoreIssues related to the Datastore API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions