Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. CONice solution. In fact, this is the best one given the description I gave of my problem. We can also enhance it: at file generation append new names at the end of the file instead of the top (avoid opening and reading the whole file), and at file access just read the first line and remove it from the text file (I'm sure there are ways to do that without having to read the whole file too). I mark this solution as the accepted answer, although the solution [given by Lucasmus is also pretty clever](http://stackoverflow.com/a/13378514/1121352).
      singulars
    2. COIn my final solution, I will implement another variant of the indexing concept: I won't generate the names randomly but using a deterministic pattern with an increasing numbering (eg: file1.ext, file2.ext, file3.ext, etc.). Then I will keep an index file that will store 2 fields: the current ID (eg: 1 for file1.ext), and the last ID of the latest generated file (eg: 1999 for file1999.ext). This has several advantages: the index file is always very short; I can always access directly a new file; and lastly I can also count the number of files left without listing the files
      singulars
    3. COby computing latestID - currentID, which allows me to run a background thread that generates new files as we run under a specified threshold. In the end, we get an almost constant access time for these two operations: accessing a file and counting the number of files left. Con is that I must be careful about concurrent accesses to the index file and the generated files to avoid unsynchronization (as a failguard, I can just regenerate it when I encounter an exception with a try: except: block).
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload