UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'dT21f55CWYEwvrJGUP3hwq6RcmCmbOTz5wEOxOqVo3g=' 
WHERE 
  key_id = '4ef733600c36f0baab4a214b76250d82df690af6e72af0c4ae0ee812689d9a81' 
  AND (
    token = 'dT21f55CWYEwvrJGUP3hwq6RcmCmbOTz5wEOxOqVo3g=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00023