服务器上的临时存储

I'm looking for an efficient and secure way to store small amount of user data like a line of text, for an indefinite period of time. The scenario: One client 'A' sends some data to another client 'B' , asynchronously via a server 'S'. For simplicity, consider the data to be a single line of text. Now, this data would be delivered to client 'B' by server 'S' , only when B asks for it. So until that time Server 'S' has to store this data.

For a simple demo, I implemented it very crudely as follows:
Client 'A' does a POST request with XMLHttpRequest, sending the text to 'S' as follows

    xhr.open("POST",url+"?sentText=text"); //url points to a php file on S
    xhr.send(); 

The PHP code then saves the received text to a file as follows:

    <?php
    $selected = $_GET["sentText"];
    $writefile = "text.txt";
    $fh = fopen($writefile,'w');
    fwrite($fh,$selected);
    fclose($fh);
    ?>

Later, after any amount of time, B asks for the text in this file,using BufferedInputStream as follows:

    URL fileurl = new URL("url/text.txt");
    BufferedReader in = new BufferedReader(new InputStreamReader(fileurl.openStream()));
    while((tmpReceived = in.readLine())!=null){
       received = tmpReceived;
    }

This demo works properly, but this is just a demo. However, if this were to be a full scale real world application with millions of users, how would I implement the following:

The part where server S stores the text. Obviously, I can't save the text as plain text in a file, as it would breach my users' privacy. And it would also be ineffecient when there are millions of users. How do commercial services like Dropbox achieve this?

To keep things simple, I just need to know how to do this for text, then I can extrapolate to other types possibly.

Thanks a lot!