module GitHub
GitHub::KV
is a key/value data store backed by MySQL (however, the backing store used should be regarded as an implementation detail).
Usage tips:
* Components in key names should be ordered by cardinality, from lowest to highest. That is, static key components should be at the front of the key and key components that vary should be at the end of the key in order of how many potential values they might have. For example, if using GitHub::KV to store a user preferences, the key should be named "user.#{preference_name}.#{user_id}". Notice that the part of the key that never changes ("user") comes first, followed by the name of the preference (of which there might be a handful), followed finally by the user id (of which there are millions). This will make it easier to scan for keys later on, which is a necessity if we ever need to move this data out of GitHub::KV or if we need to search the keyspace for some reason (for example, if it's a preference that we're planning to deprecate, putting the preference name near the beginning of the key name makes it easier to search for all users with that preference set). * All reader methods in GitHub::KV return values wrapped inside a Result object. If any of these methods raise an exception for some reason (for example, the database is down), they will return a Result value representing this error rather than raising the exception directly. See lib/github/result.rb for more documentation on GitHub::Result including usage examples. When using GitHub::KV, it's important to handle error conditions and not assume that GitHub::Result objects will always represent success. Code using GitHub::KV should be able to fail partially if GitHub::KV is down. How exactly to do this will depend on a case-by-case basis - it may involve falling back to a default value, or it might involve showing an error message to the user while still letting the rest of the page load.