hujukulu
hujukulu

Reputation: 25

Save token as file

i would like to ask if is ok to save authorization token as a file in the specific folder. Or will be faster with every request connect to database and compare with token save in the table ? Thanks for answer

Upvotes: 0

Views: 1320

Answers (1)

Smuuf
Smuuf

Reputation: 6534

From the "what's faster" standpoint...

Accessing, writing and reading files on the hard disk has its overhead and bears - compared to accessing memory - some performance loss. Databases (again, typically) also store their data on the hard disk, but also often keep data loaded in memory. That's because accessing memory is much faster than accessing files on a hard drive.

So, if you're asking...

What's faster?

The answer would be (most of the times): Database.

And does it really matter?

Depends on your application.

  • If you're having five requests per second reading your access tokens, then: no, it doesn't matter, and storing them on the disk is - performance wise - absolutely enough.
  • If you need to read access tokens (tens, hundreds of) thousands of times per second, then using a database might be a slightly better (faster) option for you.

Upvotes: 1

Related Questions