UPDATE 
  q_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'G1OtIO9S7n9Uj8CePlMBXokafr+vZh9GHc0f4A7xUwU=' 
WHERE 
  key_id = '0a1dc5adcbc1bc1cfe6ff0e05f54fcefbf6d2b2a868b1fe4bc9cfca77127c795' 
  AND (
    token = 'G1OtIO9S7n9Uj8CePlMBXokafr+vZh9GHc0f4A7xUwU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032