creating userprops
Nov. 9th, 2009 06:34 pm![[staff profile]](https://www.dreamwidth.org/img/silk/identity/user_staff.png)
Okay, I've seen people creating properties (userprops here) and putting random values for the various fields. Let me explain them, so that next time you have the good fortune of doing this, you know what to put in each field.
That is what a property looks like. You can find them in bin/upgrading/proplists.dat.
CLustered Data VERSION. The dversion of a user is, in effect, which database tables they are using. We are currently on dversion 8. This field tells the userprop system "in which dversion was this property clustered".
To make this more explicit, this helps tell the system where to find the data for the property. A value of 0 means "this property is not clustered, find it on the global". A value that is non-zero but less than or equal to the current user's dversion means the data is on one of the user cluster databases. If the value is greater than the user's dversion, then this property will be on the user clusters, but is currently on the global for this user.
If that made no sense, that's OK. Keep reading.
Will we ever want to do a reverse lookup on this property? I.e., to find which users have a value of X for this property? If YES, then cldversion = 0.
For example, it might be useful to say "hey, who has ICQ number 2903909?" and then look that up and say "oh, Mark does!" In that case, you want the property all in one location (on the global database), so set cldversion = 0.
On the other hand, if you have a property that is a setting, you don't need to do a reverse lookup. "Who has opted out of the latest posts feed?" is a question we won't ask, because the answer is (probably) "lots of people". In that case, set cldversion = 4.
Why "4"? It's traditional at this point. You could set it to anything from 1 to 8 and it would have the same impact. Just set it to 4. :-)
You almost always want this value set to 4 unless you really know you need it to be 0.
There are four valid values: char, num, bool, blobchar.
These don't matter much right now. The only thing that matters is if you use blobchar, you get forced onto the user clusters (cldversion and indexed become irrelevant). You can, however, store up to ~16MB of data in the property. (Please don't.)
All other values are business as usual. One day they might be necessary or useful but they aren't for now ...
If you think you need a blobchar property, you should probably talk to some senior developers and see what they think.
A simple, short phrase describing what this property does. It doesn't have to be long or anything, it's just referenced when we look at the file to figure out what it this property is. I'm not even sure if we use this on the site anywhere.
This is a boolean value, either 1 or 0. The implication is similar to the cldversion questions: if you need to look up users from a value, then you want to have indexed set to 1.
This value only matters if cldversion is 0! Only properties that are stored on the global can be indexed.
Most of the time you want this to be 0.
This is a useful property that doesn't matter for us right now at this scale, but for huge installations like LJ, it was a definite bacon saver.
The gist of it is that setting this allows you to have a property stored on the global database and the user clusters. Some properties have cldversion = 0, indexed = 1 because you want to be able to look them up in reverse (who has this AIM name? etc), but that puts the property on the global. This causes you to have to hit the global whenever you do something as simple as render a profile page, because those properties are only on the global!
Setting multihomed lets the property live in two places. You pay the cost of having to write twice every time the user changes the property, but it lets you get fast reads (from the user clusters) as well as indexed reads (from the global).
Most of the time you want to set this to 0 unless you have a cldversion = 0, indexed = 1 property. In that case, set it to 1.
Title case proper name for a property. Similar to the description.
In most situations, you want cldversion = 4, indexed = 0, multihomed = 0, type = bool/char. That will do for almost all settings that a user might have.
For things that you want to be searched on the global database (things that are closer to a 1:1 relationship from values to users) then you can consider cldversion = 0, indexed = 1, multihomed = 1, type = bool/char.
Avoid type = blobchar, or talk to a senior developer if you need one.
That's it. Any questions?
userproplist.icq: cldversion: 0 datatype: char des: ICQ Number indexed: 1 multihomed: 1 prettyname: ICQ
That is what a property looks like. You can find them in bin/upgrading/proplists.dat.
cldversion
CLustered Data VERSION. The dversion of a user is, in effect, which database tables they are using. We are currently on dversion 8. This field tells the userprop system "in which dversion was this property clustered".
To make this more explicit, this helps tell the system where to find the data for the property. A value of 0 means "this property is not clustered, find it on the global". A value that is non-zero but less than or equal to the current user's dversion means the data is on one of the user cluster databases. If the value is greater than the user's dversion, then this property will be on the user clusters, but is currently on the global for this user.
If that made no sense, that's OK. Keep reading.
Will we ever want to do a reverse lookup on this property? I.e., to find which users have a value of X for this property? If YES, then cldversion = 0.
For example, it might be useful to say "hey, who has ICQ number 2903909?" and then look that up and say "oh, Mark does!" In that case, you want the property all in one location (on the global database), so set cldversion = 0.
On the other hand, if you have a property that is a setting, you don't need to do a reverse lookup. "Who has opted out of the latest posts feed?" is a question we won't ask, because the answer is (probably) "lots of people". In that case, set cldversion = 4.
Why "4"? It's traditional at this point. You could set it to anything from 1 to 8 and it would have the same impact. Just set it to 4. :-)
You almost always want this value set to 4 unless you really know you need it to be 0.
datatype
There are four valid values: char, num, bool, blobchar.
These don't matter much right now. The only thing that matters is if you use blobchar, you get forced onto the user clusters (cldversion and indexed become irrelevant). You can, however, store up to ~16MB of data in the property. (Please don't.)
All other values are business as usual. One day they might be necessary or useful but they aren't for now ...
If you think you need a blobchar property, you should probably talk to some senior developers and see what they think.
des
A simple, short phrase describing what this property does. It doesn't have to be long or anything, it's just referenced when we look at the file to figure out what it this property is. I'm not even sure if we use this on the site anywhere.
indexed
This is a boolean value, either 1 or 0. The implication is similar to the cldversion questions: if you need to look up users from a value, then you want to have indexed set to 1.
This value only matters if cldversion is 0! Only properties that are stored on the global can be indexed.
Most of the time you want this to be 0.
multihomed
This is a useful property that doesn't matter for us right now at this scale, but for huge installations like LJ, it was a definite bacon saver.
The gist of it is that setting this allows you to have a property stored on the global database and the user clusters. Some properties have cldversion = 0, indexed = 1 because you want to be able to look them up in reverse (who has this AIM name? etc), but that puts the property on the global. This causes you to have to hit the global whenever you do something as simple as render a profile page, because those properties are only on the global!
Setting multihomed lets the property live in two places. You pay the cost of having to write twice every time the user changes the property, but it lets you get fast reads (from the user clusters) as well as indexed reads (from the global).
Most of the time you want to set this to 0 unless you have a cldversion = 0, indexed = 1 property. In that case, set it to 1.
prettyname
Title case proper name for a property. Similar to the description.
Summary
In most situations, you want cldversion = 4, indexed = 0, multihomed = 0, type = bool/char. That will do for almost all settings that a user might have.
For things that you want to be searched on the global database (things that are closer to a 1:1 relationship from values to users) then you can consider cldversion = 0, indexed = 1, multihomed = 1, type = bool/char.
Avoid type = blobchar, or talk to a senior developer if you need one.
That's it. Any questions?