region > persistIfPossible (API)
334439
@Override
    public boolean persistIfPossible(Command command) {
        if(!(command instanceof CommandJdo)) {
            // ought not to be the case, since this service created the object in the #create() method
            return false;
        }
        final CommandJdo commandJdo = (CommandJdo)command;
        repositoryService.persist(commandJdo);
        return true;
    }
427597
function persistObject(target, schema) {
    var model = createModel(schema);
    serializr_1.setDefaultModelSchema(target, model);
    return target;
}
1368123
@Override
    public void persistJoinTable(JoinTableData joinTableData)
    {
        String schemaName = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, joinTableData.getEntityClass())
                .getSchema();
        String joinTableName = joinTableData.getJoinTableName();
        String joinColumnName = joinTableData.getJoinColumnName();
        String invJoinColumnName = joinTableData.getInverseJoinColumnName();

        Map<Object, Set<Object>> joinTableRecords = joinTableData.getJoinTableRecords();

        for (Object key : joinTableRecords.keySet())
        {
            Set<Object> values = joinTableRecords.get(key);
            insertRecordInJoinTable(schemaName, joinTableName, joinColumnName, invJoinColumnName, key, values);
        }
    }
780119
public void getPersistentData(ObjectOutputStream oos)
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "getPersistentData", oos);

    super.getPersistentData(oos);
    
    try
    {
      HashMap hm = new HashMap();

      if (durableSubName != null)
        hm.put("durableSubName", durableSubName);
      
      oos.writeObject(hm);
    }
    catch (IOException e)
    {
      // FFDC
      FFDCFilter.processException(
        e,
        "com.ibm.ws.sib.processor.impl.store.itemstreams.PtoPReceiveMsgsItemStream.getPersistentData",
        "1:301:1.26.1.2",
        this);
        
      SibTr.exception(tc, e);
      if (tc.isEntryEnabled()) SibTr.exit(tc, "getPersistentData", "SIErrorException");
      
      throw new SIErrorException(
       nls.getFormattedMessage(
        "INTERNAL_MESSAGING_ERROR_CWSIP0003",
        new Object[] {
          "com.ibm.ws.sib.processor.impl.store.itemstreams.PtoPMessageItemStream",
          "1:312:1.26.1.2",
          e,
          getDestinationHandler().getName()},
        null),
        e);
    }

    if (tc.isEntryEnabled())
      SibTr.exit(tc, "getPersistentData");
  }
12267
function persistSubscriptionLocally(subscription) {
    let subscriptionJSON = JSON.stringify(subscription);
    idb.open('web-push-db', 1).then(db => {
        let tx = db.transaction(['web-push-subcription'], 'readwrite');
        tx.objectStore('web-push-subcription').put({
            id: 1,
            data: subscriptionJSON
        });
        return tx.complete;
    });
}
700046
public void savePersistentObject(PersistentObject object) {
        final String type = object.getClass().getSimpleName();
        LOG.trace("Trying to create a new " + type);
        dao.saveOrUpdate(object);
        LOG.info("Created the " + type + " with id " + object.getId());
    }
208948
public Collection<Object> persist(Collection<Object> objColl) {
    if (null == objColl) {
      throw new IllegalArgumentException("object to save cannot be null");
    }

    objMapper.saveObjCollection(keyspace, objColl);
    return objColl;
  }
1062890
function persist(pErr, pVal) {
          if (pErr) {
            return cb(pErr);
          }

          if (ttl) {
            conn.setex(key, ttl, pVal, handleResponse(conn, cb));
          } else {
            conn.set(key, pVal, handleResponse(conn, cb));
          }
        }
585517
function onSetPersistence() {
  var type = $('#persistence-type').val();
  try {
    auth.setPersistence(type).then(function() {
      log('Persistence state change to "' + type + '".');
      alertSuccess('Persistence state change to "' + type + '".');
    }, function(error) {
      alertError('Error: ' + error.code);
    });
  } catch (error) {
    alertError('Error: ' + error.code);
  }
}
993629
public long persist(File persistFile) {
        try {
            FileOutputStream fileStream = new FileOutputStream(persistFile);
            ObjectOutputStream oStream = new ObjectOutputStream((fileStream));

            long persistVersion;
            Map<String, ChangedFile> fileListCopy;
            synchronized (this) {
                fileListCopy = (Map<String, ChangedFile>) fileList.clone();
                fileListCopy.putAll(reservedFiles);
                persistVersion = listVersion;
            }

            oStream.writeObject(fileListCopy);
            oStream.close();
            return persistVersion;
        } catch (IOException e) {
            throw new RuntimeException("Unable to persist File Changed List:" +
                                       e.getMessage(), e);
        }
    }
922926
private void parsePersistence(Map<Object, Object> props) {
        parseKeepAliveEnabled(props);
        if (isKeepAliveEnabled()) {
            parseMaxPersist(props);
        }
    }
62911
def persist(self, storageLevel):
        
        self.is_cached = True
        javaStorageLevel = self._sc._getJavaStorageLevel(storageLevel)
        self._jdstream.persist(javaStorageLevel)
        return self
319497
@Override
   public synchronized void retain() throws RepositoryException
   {
      try
      {
         if (!isRetainable())
            throw new RepositoryException("Unsupported  configuration place "
               + configurationService.getURL(param.getValue())
               + " If you want to save configuration, start repository from standalone file."
               + " Or persister-class-name not configured");

         OutputStream saveStream = null;

         if (configurationPersister != null)
         {
            saveStream = new ByteArrayOutputStream();
         }
         else
         {
            URL filePath = configurationService.getURL(param.getValue());
            final File sourceConfig = new File(filePath.toURI());
            final File backUp = new File(sourceConfig.getAbsoluteFile() + "." + indexBackupFile++);

            if (indexBackupFile > maxBackupFiles)
            {
               indexBackupFile = 1;
            }

            try
            {
               SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Void>()
               {
                  public Void run() throws IOException
                  {
                     DirectoryHelper.deleteDstAndRename(sourceConfig, backUp);
                     return null;
                  }
               });
            }
            catch (IOException ioe)
            {
               throw new RepositoryException("Can't back up configuration on path "
                  + PrivilegedFileHelper.getAbsolutePath(sourceConfig), ioe);
            }

            saveStream = PrivilegedFileHelper.fileOutputStream(sourceConfig);
         }

         IBindingFactory bfact;
         try
         {
            bfact = SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<IBindingFactory>()
            {
               public IBindingFactory run() throws Exception
               {
                  return BindingDirectory.getFactory(RepositoryServiceConfiguration.class);
               }
            });
         }
         catch (PrivilegedActionException pae)
         {
            Throwable cause = pae.getCause();
            if (cause instanceof JiBXException)
            {
               throw (JiBXException)cause;
            }
            else if (cause instanceof RuntimeException)
            {
               throw (RuntimeException)cause;
            }
            else
            {
               throw new RuntimeException(cause);
            }
         }
         
         IMarshallingContext mctx = bfact.createMarshallingContext();

         mctx.marshalDocument(this, "ISO-8859-1", null, saveStream);
         saveStream.close();

         // writing configuration in to the persister
         if (configurationPersister != null)
         {
            configurationPersister.write(new ByteArrayInputStream(((ByteArrayOutputStream)saveStream).toByteArray()));
         }
      }
      catch (JiBXException e)
      {
         throw new RepositoryException(e);
      }
      catch (FileNotFoundException e)
      {
         throw new RepositoryException(e);
      }
      catch (IOException e)
      {
         throw new RepositoryException(e);
      }
      catch (RepositoryConfigurationException e)
      {
         throw new RepositoryException(e);
      }
      catch (Exception e)
      {
         throw new RepositoryException(e);
      }
   }
553082
@Override
    public void persistJoinTable(JoinTableData joinTableData)
    {
        String joinTableName = joinTableData.getJoinTableName();
        String joinColumnName = joinTableData.getJoinColumnName();
        String invJoinColumnName = joinTableData.getInverseJoinColumnName();
        Map<Object, Set<Object>> joinTableRecords = joinTableData.getJoinTableRecords();

        for (Object key : joinTableRecords.keySet())
        {
            Set<Object> values = joinTableRecords.get(key);
            Object joinColumnValue = key;

            for (Object childId : values)
            {
                Map<String, Object> obj = new HashMap<String, Object>();
                String id = joinTableName + "#" + joinColumnValue.toString() + "#" + childId;
                obj.put("_id", id);
                obj.put(joinColumnName, joinColumnValue);
                obj.put(invJoinColumnName, childId);
                JsonObject object = gson.toJsonTree(obj).getAsJsonObject();
                HttpResponse response = null;
                try
                {
                    URI uri = new URI(CouchDBConstants.PROTOCOL, null, httpHost.getHostName(), httpHost.getPort(),
                            CouchDBConstants.URL_SEPARATOR + joinTableData.getSchemaName().toLowerCase()
                                    + CouchDBConstants.URL_SEPARATOR + id, null, null);

                    HttpPut put = new HttpPut(uri);
                    StringEntity stringEntity = null;
                    stringEntity = new StringEntity(object.toString(), Constants.CHARSET_UTF8);
                    stringEntity.setContentType("application/json");
                    put.setEntity(stringEntity);

                    response = httpClient.execute(httpHost, put, CouchDBUtils.getContext(httpHost));
                }
                catch (Exception e)
                {
                    log.error("Error while persisting joinTable data, coused by {}.", e);
                    throw new KunderaException(e);
                }
                finally
                {
                    closeContent(response);
                }
            }
        }
    }
718501
public synchronized void persistProperties() throws IOException {
        beginPersistence();

        // Read the properties file into memory
        // Shouldn't be so bad - it's a small file
        List<String> content = readFile(propertiesFile);

        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(propertiesFile), StandardCharsets.UTF_8));

        try {
            for (String line : content) {
                String trimmed = line.trim();
                if (trimmed.length() == 0) {
                    bw.newLine();
                } else {
                    Matcher matcher = PROPERTY_PATTERN.matcher(trimmed);
                    if (matcher.matches()) {
                        final String key = cleanKey(matcher.group(1));
                        if (toSave.containsKey(key) || toSave.containsKey(key + DISABLE_SUFFIX_KEY)) {
                            writeProperty(bw, key, matcher.group(2));
                            toSave.remove(key);
                            toSave.remove(key + DISABLE_SUFFIX_KEY);
                        } else if (trimmed.startsWith(COMMENT_PREFIX)) {
                            // disabled user
                            write(bw, line, true);
                        }
                    } else {
                        write(bw, line, true);
                    }
                }
            }

            endPersistence(bw);
        } finally {
            safeClose(bw);
        }
    }
570908
private void captureUploadStateIfPossible() {
        if (origReq.getSSECustomerKey() == null) {
            persistableUpload = new PersistableUpload(origReq.getBucketName(),
                    origReq.getKey(), origReq.getFile()
                            .getAbsolutePath(), multipartUploadId,
                    configuration.getMinimumUploadPartSize(),
                    configuration.getMultipartUploadThreshold());
            notifyPersistableTransferAvailability();
        }
    }
770334
private PersistedRecoveryPaxosData getPersistedPaxosData(long segmentTxId)
      throws IOException {
    File f = journalStorage.getPaxosFile(segmentTxId);
    if (!f.exists()) {
      // Default instance has no fields filled in (they're optional)
      return null;
    }
    
    InputStream in = new FileInputStream(f);
    try {
      PersistedRecoveryPaxosData ret = PersistedRecoveryPaxosData.parseDelimitedFrom(in);
      Preconditions.checkState(ret != null &&
          ret.getSegmentState().getStartTxId() == segmentTxId,
          "Bad persisted data for segment %s: %s",
          segmentTxId, ret);
      return ret;
    } finally {
      IOUtils.closeStream(in);
    }
  }