UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'G7Pfu3DmYNXXxUIWUJ6EqzQW42kW216WGh0mO2Zz9Rk=' 
WHERE 
  key_id = '5120401838114199442eaef688054ab6611298502c25f7af6409d5032dcc07f7' 
  AND (
    token = 'G7Pfu3DmYNXXxUIWUJ6EqzQW42kW216WGh0mO2Zz9Rk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00048