docs: int writeValueSet(int type, Object id, ValueSet vs, boolean all) {
          final String methodName = "writeValueSet()";
          int returnCode = NO_EXCEPTION;
          Exception diskException = null;
          HashtableOnDisk cache_instance = null;
          if (vs.size() == 0) {
              return returnCode;
          }
          HashtableOnDisk vshtod = null;
          try {
              rwLock.writeLock().lock();
              if (type == DEP_ID_DATA) {
                  cache_instance = dependency_cache;
              } else {
                  cache_instance = template_cache;
              }
              //if (this.testException) {
              //    throw new FileManagerException("*** Generate filemanager exception");
              //}
              Long vsinstid = (Long) cache_instance.get(id);
              long vsinstance = 0;
              FileManager filemgr = cache_instance.getFileManager();
              if (vsinstid == null) {
                  //
                  // no such instance as yet.  Make one and put its pointer into the main valueset htod.
                  //
                  int valueSize = calculateTableSize(id, vs.size());
                  vsinstance = HashtableOnDisk.createInstance(filemgr, valueSize, hashtable_threshold);
                  vshtod = HashtableOnDisk.getInstance(filemgr, valueset_rehash, vsinstance, !HashtableOnDisk.HAS_CACHE_VALUE, this);
                  cache_instance.put(id, new Long(vsinstance));
              } else {
                  //
                  // Existing instance.  Get it and clear it.
                  // Is this right?  In the original code this method completely replaced the
                  // existing valueset we I assume we want to do that here also.  If we don't
                  // clear it this method would perform a merge.  If a merge is ok then we
                  // can skip this step with potential for significant performance benefit.
                  //
                  // I don't think we should clear
                  vsinstance = vsinstid.longValue();
                  if (vsinstance != -1) {
                      vshtod = HashtableOnDisk.getInstance(filemgr, valueset_rehash, vsinstance, !HashtableOnDisk.HAS_CACHE_VALUE, this);
                  } else {
                      int valueSize = calculateTableSize(id, vs.size());
                      vsinstance = HashtableOnDisk.createInstance(filemgr, valueSize, hashtable_threshold);
                      vshtod = HashtableOnDisk.getInstance(filemgr, valueset_rehash, vsinstance, !HashtableOnDisk.HAS_CACHE_VALUE, this);
                      cache_instance.put(id, new Long(vsinstance));
                  }
                  // pass the new table size to HashtableOndisk so that it can use it to rehash
                  if (all == ALL) {
                      if (vshtod.size() > 0) {
                          vshtod.clear();
                      }
                      vshtod.tempTableSize = calculateTableSize(id, vs.size());
                  } else {
                      vshtod.tempTableSize = calculateTableSize(id, vshtod.size() + vs.size());
                  }
                  //if (vshtod.size() < vs.size()) {
                  //    // pass the new table size to HashtableOndisk so that it can use it to rehash
                  //    vshtod.tempTableSize = calculateTableSize(id, vs.size());
                  //}
                  //vshtod.clear();
              }
  
              Object entry = null;
              do {
                  entry = vs.getOne();
                  if (entry != null) {
                      vshtod.put(entry, null); // value is null - better performance by skipping serialization and deserialization
                      vs.remove(entry);
                  }
              } while (entry != null);
  
              vshtod.close();
              vshtod = null;
          } catch (FileManagerException ex) {
              this.diskCacheException = ex;
              diskException = ex;
              returnCode = DISK_EXCEPTION;
          } catch (HashtableOnDiskException ex) {
              this.diskCacheException = ex;
              diskException = ex;
              returnCode = DISK_EXCEPTION;
          } catch (IOException ex) {
              diskException = ex;
              if (ex.getMessage().equals(DISK_CACHE_IN_GB_OVER_LIMIT_MSG)) {
                  returnCode = DISK_SIZE_OVER_LIMIT_EXCEPTION;
              } else {
                  this.diskCacheException = ex;
                  returnCode = DISK_EXCEPTION;
              }
          } catch (Exception ex) {
              returnCode = OTHER_EXCEPTION;
              diskException = ex;
          } finally {
              if (returnCode != NO_EXCEPTION) {
                  if (tc.isDebugEnabled())
                      Tr.debug(tc, methodName, "cacheName=" + this.cacheName + "\n Exception: " + ExceptionUtility.getStackTrace(diskException));
              }
              if (returnCode == DISK_EXCEPTION || returnCode == OTHER_EXCEPTION) {
                  com.ibm.ws.ffdc.FFDCFilter.processException(diskException, "com.ibm.ws.cache.HTODDynacache.writeValueSet", "1738", this);
              }
              try {
                  if (vshtod != null) {
                      vshtod.close();
                  }
              } catch (Exception ex) {
                  com.ibm.ws.ffdc.FFDCFilter.processException(ex, "com.ibm.ws.cache.HTODDynacache.writeValueSet", "1745", this);
              }
              rwLock.writeLock().unlock();
          }
  
          return returnCode;
      }