UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'O7zhyVaLHlFZ0Coi6jt8qKKypDSg2wWJ0NkJi0NUW+k=' 
WHERE 
  key_id = '3aae1f1a1a7d1a864dbf6267104da88d0269023363b69c4877610728e69b4a51' 
  AND (
    token = 'O7zhyVaLHlFZ0Coi6jt8qKKypDSg2wWJ0NkJi0NUW+k=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032