Home  >  Article  >  Backend Development  >  Need to save a certain value for a long time without writing it into the database

Need to save a certain value for a long time without writing it into the database

WBOY
WBOYOriginal
2016-12-01 01:27:44912browse

I am making a lottery system, with 1 first prize, 10 second prizes, and 100 third prizes. Now I need to save the winning numbers to see if there are enough people for a certain prize, but this is written in The database is a bit overkill. How do you save it when you encounter this?

Reply content:

I am making a lottery system, with 1 first prize, 10 second prizes, and 100 third prizes. Now I need to save the winning numbers to see if there are enough people for a certain prize, but this is written in The database is a bit overkill. How do you save it when you encounter this?

It is stored in a file. In fact, the database also stores files.

Just throw it into the file. This kind of temporarily stored data is either a file or a cache. You can also throw it into redis. It has its own sorting

Front-end storage localStorage

Put it in the cache redis

file_put_content save the file

Treat it as a configuration and write it in the configuration.

Write an XML file to save

If you don’t want to store a database, you can store files, shared memory (such as shared memory related functions, apc, apcu), memcached, redis, etc.
But these themselves are at risk of loss. If you don’t want your lottery winners to be lost suddenly, It is better to put it in the database, data loss will be more troublesome.

You can put it in the redis cache

Store in a file or write to cache or write to configuration file

This is not too much to save data! Since it is useful, it is still possible to count and check it on a certain day of the year, month and day, and it is good to save it in the database!

Isn’t sqlite the solution to this situation?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn