UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'mg5nKtig+/Vcx23RQwrR5ZGO0360POguGbkccwoAeaU=' 
WHERE 
  key_id = 'ed8dea320844ac69f5e82f3fe39718bc0983d6a13c1d2786ce55b875f293268d' 
  AND (
    token = 'mg5nKtig+/Vcx23RQwrR5ZGO0360POguGbkccwoAeaU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00042