UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'apm37+1KMTSaW7gTgoymm/V9Ieh49+QZRGULSRtUjns=' 
WHERE 
  key_id = 'd020e7252c6e6cb5d1840b3c3a82ffdb45020268519393d2e8726009c003b0b3' 
  AND (
    token = 'apm37+1KMTSaW7gTgoymm/V9Ieh49+QZRGULSRtUjns=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00022