function [OK, serKey, serWarnings] = remoteStoreSerDeser(serVal, keysToClear)
% Add value to value store and return storage key or error

% Copyright 2021 The MathWorks, Inc.


wc = parallel.internal.general.WarningsCollector();
try
    val = parallel.internal.pool.optionallyDeserialize(serVal);
    [OK, key] = spmdlang.remoteStorePlain(val, keysToClear);
    serKey = parallel.internal.pool.optionallySerialize(key);
catch E
    OK = false;
    serKey = parallel.internal.pool.optionallySerialize(E);
end

serWarnings = parallel.internal.pool.optionallySerialize(wc.Warnings);


end
