UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'xK1VEwhm+7URol7m58YVRcDyidlxi0u7YPqKQT82NF8=' 
WHERE 
  key_id = '961ba5c340edb24651e981c89554fa7d33792bfbf26307c186fecef61c818188' 
  AND (
    token = 'xK1VEwhm+7URol7m58YVRcDyidlxi0u7YPqKQT82NF8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00048