UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'agHTXXs769Z/JmNUyzPDI0iO85gUkpu17RPpz6aelD8=' 
WHERE 
  key_id = '9c64b4b76857809ea44290fa686a701a0bde47534cacd1b657b9412fbbcffd2e' 
  AND (
    token = 'agHTXXs769Z/JmNUyzPDI0iO85gUkpu17RPpz6aelD8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024