Explain to the teapot, where does the memcache object key come from?

I, like, mastered the script that will put a certain static code (into that object) in memcache. But I can not understand how this object is assigned a key when saving it in memcache?

As far as I understand, some analogies with autoincrement are not suitable here.

Explain, please, for the "stupid" - the most simple words. Thank!

  • one
    In fact, you know where to get it from. Nobody will say that for you. You save some data in the cache and you want to be able to get it from there when it is needed. Then you need to answer the question: "what data does the requesting information from the cache have at the time of the request?" The key is to build here just from what you know when you want to get the value from the cache. And it could be anything: the entity id is somewhere else, the page title, md5 from the content (though from where would the requester know this md5) - Mike
  • Thank you, Mike. Is it possible to use basename ($ _ SERVER ["REQUEST_URI"]) as this key ?? - Natalia
  • one
    Yes, well, if you use overwriting (in .htaccess) and the last component of the transmitted url is not the name of your .php file - Mike
  • I just wanted to use the file name. - Natalya
  • one
    I just for some reason thought that you have only one file. And if you have a lot of them and the code that includes the cache in them, then yes, you can use them of course. - Mike

0