UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'GQrEfrNBDbZr0TB07T+jOC5CEl0cKv5g9obc2Ss7V98=' 
WHERE 
  key_id = '40e3cca28ff892dff6af503080d30b34faa9ce181620e38ff28eec02c5672461' 
  AND (
    token = 'GQrEfrNBDbZr0TB07T+jOC5CEl0cKv5g9obc2Ss7V98=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00051