Closed (outdated)
Project:
Keys
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
19 Mar 2008 at 19:51 UTC
Updated:
24 Sep 2020 at 19:24 UTC
Jump to comment: Most recent
Comments
Comment #1
greenskin commentedI'm not so keen on using variables, and I'm not sure of the best method to cache them. Our development workflow consists four different environments: local, dev site, beta site, and a live site. The module was built most specifically for use with the Google Map API key but knew that other API keys could be used with it. So storing four (for workflows like ours) separate keys instead of one for every API seems a bit inflated.
If you know of a good method to cache only the keys for a specific domain, I'm all ears. And thanks for you interest in this module.
Comment #2
avpadernoVariables created with
variable_set()are automatically cached from Drupal.When the saved values are few, it's generally preferable to use variables which, in any cases, are saved in a table. I would think that to create a table is not worth the time spent to add the necessary code, in such cases.
Comment #3
greenskin commentedThe reasoning for not using variables is because each site would load variables that it would never use, for instance a key for a localhost would load everytime as a variable for example.com.
Comment #4
avpadernoAs long as the module returns the right key, and it is able to handle the case when it has two keys with the same name for two different domains that should not be a problem.
I don't think one web site could have more than 10-15 keys to register, so loading them all together should not be a problem, IMHO.
Comment #5
gagarine commented+1 and a key is a tiny data so any way you can have 30 keys without see any performance change...
Comment #6
gagarine commentedComment #7
greenskin commentedIf someone is willing to supply a patch I'm willing to make the switch. I'm unclear of the best method to get the correct key based on the keys rule. For example if you have two keys, one has a rule for 'www.example.com' and the other has a rule for 'www.example.com/subsite'. How do you choose which key to grab. Currently this is done using SQL's LOCATE method (LOCATE should be changed to LIKE and use wildcards but that is a separate issue) then sorted by the length of the rule in DESC order (longest rule first essentially).
So what would be the best method to determine the appropriate key to use if keys are stored as variables? Regular expressions would obviously be the tool to use, but I'm no regex guru; I have to look at my cheat sheet whenever I need to use them.
Comment #8
gagarine commentedCheck http://api.drupal.org/api/function/variable_set
"$value The value to set. This can be any PHP data type; these functions take care of serialization as necessary."
So instead of storing a value for each keys. It would be perhaps easier to store a array with all the keys.
like
Comment #9
greenskin commented@gagarine Yes that is what I expect to do, store all the keys in one variable. My question was when a request is made to return a key, how to determine the appropriate key to return.
I envision the variable to look something like this:
Comment #10
gagarine commentedI need to try the code on my computer to see really how keys module work. But I think the API can be simpler.
I don't like the $param param because he can be a lot of different things.
So this is a concept
EDIT ok I understand now the problem is keys_get_url() can give a different url... and we only need domaine or subdomaine... why so don't use keys_get_domain() instead?
Comment #11
greenskin commented@gagarine Keys are returned based on URL rather than just the domain because API services like Google generate keys not just dependent on the domain. Also, if your site were example.com/mysite, you would need to distinguish keys for that site specifically. Of course Google's key would work for all subdirectories if you created the key using just the domain, but some people might want to better control which sites can use the API with what key.
Comment #12
avpadernoI am closing this issue, since it's for a not supported Drupal version.