Creates a lock ID where the lower bits are the group ID and the upper bits
  are the item ID. This allows the use of a bigint namespace for items, with a
  limited space for grouping.

  :group_id: an integer identifying the group. Must be less than
             2 ^ :group_width:
  :item_id: item_id an integer. must be less than 2 ^ (63 - :group_width:) - 1
  :gropu_width: the number of bits to reserve for the group ID.

def lock_key(group_id, item_id, group_width=8):
  """Creates a lock ID where the lower bits are the group ID and the upper bits
  are the item ID. This allows the use of a bigint namespace for items, with a
  limited space for grouping.

  :group_id: an integer identifying the group. Must be less than
             2 ^ :group_width:
  :item_id: item_id an integer. must be less than 2 ^ (63 - :group_width:) - 1
  :gropu_width: the number of bits to reserve for the group ID.
  """
  if group_id >= (1 << group_width):
    raise Exception("Group ID is too big")
  if item_id >= (1 << (63 - group_width)) - 1:
    raise Exception("Item ID is too big")
  return (item_id << group_width) | group_id