UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'aBh1gMjuxaLr+k/1i7XXFXvWvjz1NfNooJdJMUScbUk=' 
WHERE 
  key_id = 'aa0832b001e7a9dd17db02016d8e5ff67adf83573e68c1d0e0defa4601c1b2d1' 
  AND (
    token = 'aBh1gMjuxaLr+k/1i7XXFXvWvjz1NfNooJdJMUScbUk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038