J
J
jacksparrow2016-02-28 22:41:18
Yii
jacksparrow, 2016-02-28 22:41:18

How to properly implement array caching?

When working with api, due to restrictions, there is a need to remember application keys that have exceeded the 15-minute access limit. As a result, there is a need to cache the key for 15 minutes in order not to pull it again. But the expiration time can only be set for the entire array, but not for each element. I would like to immediately access the expired_keys array, getting all the keys that are currently invalid. Writing a cache inside a cache, so that each element is additionally checked for expired, does not seem like a good idea.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita, 2016-02-29
@bitver

About 15 minutes some blah blah blah, correct me if I'm wrong. Some kind of mythical array, at least a line of code. I know that you need to write the keys to the cache with a common prefix, and write the keys of the key array separately (separated by commas, for example). The first is a common practice for key-value databases, and the second is in case your database cache doesn't know how to search by prefixes.
Like this 'my_prefix.'. $key => $apiKey;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question