UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'wZWcBweQlmOa4+++Fow6btfXBnJugtBoPk6fS1/DzPM=' 
WHERE 
  key_id = '51f8e342a6901323e0b15cb48d190bee05469c7b8ac596b62a0fef845810835c' 
  AND (
    token = 'wZWcBweQlmOa4+++Fow6btfXBnJugtBoPk6fS1/DzPM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00052