UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'kq4s1CU71F1cYAAZoqXADYYw0iiuJYG3XesVVxavCU4=' 
WHERE 
  key_id = 'cf713c9197f0c2025a616fed9fad97168a80870147fc32475235d079a6ac8749' 
  AND (
    token = 'kq4s1CU71F1cYAAZoqXADYYw0iiuJYG3XesVVxavCU4=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00016