UPDATE 
  q_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'kx4U522EPzDYZnssvHWaW55Hj9uX7DfG13VmDfA6y88=' 
WHERE 
  key_id = 'bdbd985eb516ba196820457acca41176e921def9168ce48499c1c8c44f607f5b' 
  AND (
    token = 'kx4U522EPzDYZnssvHWaW55Hj9uX7DfG13VmDfA6y88=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00028