code: @Override
      protected Object save(final NoSqlSession session, final Object version, final boolean activateAfterSave)
      {
          try
          {
              log.debug("save:" + session);
              session.willPassivate();
  
              if (!session.isValid())
              {
                  log.debug("save: skip saving invalidated session: id=" + session.getId());
                  deleteKey(session.getId());
                  return null;
              }
  
              ISerializableSession data;
              synchronized (session)
              {
                  data = getSessionFactory().create(session);
              }
              data.setDomain(_cookieDomain);
              data.setPath(_cookiePath);
              long longVersion = 1; // default version for new sessions
              if (version != null)
              {
                  longVersion = (Long) version + 1L;
              }
              data.setVersion(longVersion);
  
              try
              {
                  if (!setKey(session.getId(), data))
                  {
                      throw (new RuntimeException("unable to set key: data=" + data));
                  }
              }
              catch (TranscoderException error)
              {
                  throw (new IllegalArgumentException("unable to serialize session: id=" + session.getId() + ", data="
                      + data, error));
              }
              log.debug("save:db.sessions.update(" + session.getId() + "," + data + ")");
  
              if (activateAfterSave)
              {
                  session.didActivate();
              }
  
              return longVersion;
          }
          catch (Exception e)
          {
              log.warn(e);
          }
          return null;
      }
docs: /* ------------------------------------------------------------