UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'eWmATKuhI+CWxuLszVhM0pA1noD/REx9aXdkEkAUbMo=' 
WHERE 
  key_id = '4fdd618bd659a7596f749cdd5c7eade2320d4b3eee87e28b92d3feee1175e7a5' 
  AND (
    token = 'eWmATKuhI+CWxuLszVhM0pA1noD/REx9aXdkEkAUbMo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038