UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'xmkm+NdAYmGqV9zsKCjnJ9Kzit9D/zYKIwPtKGHkvcU=' 
WHERE 
  key_id = '0e40164ee3364240f9168103886ea41c369d6ab9c9e52476786056914d6716ea' 
  AND (
    token = 'xmkm+NdAYmGqV9zsKCjnJ9Kzit9D/zYKIwPtKGHkvcU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00050