UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'P6rTtF8EdQUUHQ+Ff93skERwa94DWtnJlHUMK6f+JRo=' 
WHERE 
  key_id = 'dc994e841e3986e1b84693d6b4b8de5c10754ff96099de4d1e1482e3a1763762' 
  AND (
    token = 'P6rTtF8EdQUUHQ+Ff93skERwa94DWtnJlHUMK6f+JRo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037