This adds a KeyLock struct and related functions trying to keep the same
semantic of DirLock.
KeyLock is a lock for a specific key. The lock file is created inside a
directory using the key name.
This is useful when multiple processes want to take a lock but cannot use
FileLock as they don't have a well defined file on the filesystem.
For example it's needed for image file locking and in future for download locking