UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Mm/UStfRLDYaJcpEl50y1JQ2HhUWEh6kokvNnFnPMBU=' 
WHERE 
  key_id = '77357ebaa2ea7223fe226d7ff165c98b9415adb9a19758655c107fdce4032830' 
  AND (
    token = 'Mm/UStfRLDYaJcpEl50y1JQ2HhUWEh6kokvNnFnPMBU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040