UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ccS5IyCTcrfjM7niomychan3M7prkXVT6u4NdyNNL1E=' 
WHERE 
  key_id = 'd5c07652b274d0c42913d7c8de735c08e35a7c294dca1ccda0c881795efcb329' 
  AND (
    token = 'ccS5IyCTcrfjM7niomychan3M7prkXVT6u4NdyNNL1E=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00028