/** @see org.eclipse.jetty.nosql.NoSqlSessionManager#expire(java.lang.String) */
  @Override
  protected void expire(String idInCluster) {
    __log.debug("KVStoreSessionManager:expire session {} ", idInCluster);

    // Expire the session for this context
    super.expire(idInCluster);

    // If the outer session document has not already been marked invalid, do so.
    ValueVersion vver_valid =
        _kvstorehandler.get(
            Key.createKey(Arrays.asList(__storeprefix, idInCluster), Arrays.asList(__VALID)));

    try {
      if (vver_valid != null
          && vver_valid.getValue() != null
          && vver_valid.getValue().getValue() != null
          && "0".equals(new String(vver_valid.getValue().getValue(), "UTF-8"))) {
        if (this.kvstore_opfactory == null)
          this.kvstore_opfactory = this._kvstorehandler.getOperationFactory();
        kvstore_object_ops.clear();
        kvstore_object_ops.add(
            this.kvstore_opfactory.createPut(
                Key.createKey(Arrays.asList(__storeprefix, idInCluster), Arrays.asList(__VALID)),
                Value.createValue("0".getBytes("UTF-8"))));
        kvstore_object_ops.add(
            this.kvstore_opfactory.createPut(
                Key.createKey(
                    Arrays.asList(__storeprefix, idInCluster), Arrays.asList(__INVALIDATED)),
                Value.createValue(
                    Base62Converter.fromBase10(System.currentTimeMillis()).getBytes("UTF-8"))));

        // update indexes
        // delete old entries, if present
        ValueVersion old_valid =
            _kvstorehandler.get(
                Key.createKey(Arrays.asList(__storeprefix, idInCluster), Arrays.asList(__VALID)));
        __log.debug("old_valid=" + (old_valid != null ? "notnull" : "null"));
        ValueVersion old_accessed =
            _kvstorehandler.get(
                Key.createKey(
                    Arrays.asList(__storeprefix, idInCluster), Arrays.asList(__ACCESSED)));
        __log.debug("old_accessed=" + (old_accessed != null ? "notnull" : "null"));
        if (old_valid != null
            && old_valid.getValue() != null
            && old_valid.getValue().getValue() != null
            && old_accessed != null
            && old_accessed.getValue() != null
            && old_accessed.getValue().getValue() != null) {
          __log.debug("deleting old purgeindex entry");
          _kvstorehandler.delete(
              Key.createKey(
                  Arrays.asList(
                      __purgeindexprefix,
                      new String(old_valid.getValue().getValue(), "UTF-8"),
                      new String(old_accessed.getValue().getValue(), "UTF-8")),
                  Arrays.asList(idInCluster)));
        } else __log.debug("some keys for purge index missing, nothing to delete");

        _kvstorehandler.put(
            Key.createKey(
                Arrays.asList(
                    __purgeindexprefix,
                    "0",
                    new String(old_accessed.getValue().getValue(), "UTF-8")),
                Arrays.asList(idInCluster)),
            Value.EMPTY_VALUE);

        if (kvstore_object_ops.size() > 0) {
          _kvstorehandler.execute(kvstore_object_ops);
          kvstore_object_ops.clear();
        }
      }
    } catch (UnsupportedEncodingException | OperationExecutionException | FaultException e) {
      __log.debug(
          "KVStoreSessionManager: expire :: error :: session {} context {} ",
          idInCluster,
          _contextId);
    }
  }