UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'p/NGcl4LEGFk3VmEVAb0Da1Nj7prncppG3kC5wBNRlU=' 
WHERE 
  key_id = '416ffa400d4a6b434950618c649d1841bc62f4379412d09041e64aa6b242874b' 
  AND (
    token = 'p/NGcl4LEGFk3VmEVAb0Da1Nj7prncppG3kC5wBNRlU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034