UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'wJ4z7SWJE4LZu9U5xBwCXInBpiDuIHFEI/f+Bq3uVGk=' 
WHERE 
  key_id = 'ce768284d71e2cf1d369b44b64885fad49bc3da302efb7209eb07dd47e685268' 
  AND (
    token = 'wJ4z7SWJE4LZu9U5xBwCXInBpiDuIHFEI/f+Bq3uVGk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00046