UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '4d3dO4c+dSPxRu6ggfJpFihvvSM6g0UiWo8xiezxvfg=' 
WHERE 
  key_id = '3b717ff9c5131579b108c2546adbc61fd91326d5bb48c9940332a98574460654' 
  AND (
    token = '4d3dO4c+dSPxRu6ggfJpFihvvSM6g0UiWo8xiezxvfg=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00027