I’ve build a small web-service in PHP. I want to control the number of calls to a specific API method.
I thought at first of using a text file, because it’s just an integer. But after taking a good look at SQLite it seemed much more convenient. So the code is just: get the ‘counter’ from SQLite and increment it when that method is called, then store it back on SQLite db.
Is this a right way of doing it? Would it be simpler and more scalable to just use a file or… maybe something else?
Thanks in advance.
Put it in a real database both a textfile, and a SQLite DB will have locking issues where if the file(s) is currently open and a new request to open it happens the second request will error out. Use a real DB like MySQL, MSSQL, or whatever is available.